Problems regarding "Hello, World!"
Hello, I have some small problems with running my first Java program through MSDOS. As a student starting a Computer Science course this October,I have been asked to familiarise myself with the language before the course begins.
To begin with I downloaded the JDK Beta 2 here. I then followed this tutorial, also from the Sun site here.
Now the problems initially occur when, after saving the code above as HelloWorldApp.java and then attempting to compile it in the command prompt window. I get an error message stating "javac is not a recognized external or internal command..."
I have found a way around this by creating an env.bat file with the following:
However surely I am not required to run env.bat each time I attempt to compile my program?
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0
The second problem then occurs after compiling the program and creating the corresponding .class file. After attempting to run the completed file I recieve another error message "Exception in thread "main" java.lang.NoClassDefFoundError:".
Again I can get around this using:
However, again this cannot be the correct way to go about running my program?
java -cp . HelloWorldApp
Any help is much appreciated, as I have only just began to learn the language.
I have installed JDK1.4 into c drive so I have written follwing command in system variable Path
After setting variable restart your computer.
Now you can compile and run program from yor directroy.
After writing source compile it using follwing command
Create HTML file for your applet writing this code in body tag.
<APPLET CODE="FileName.class" WIDTH=150 HEIGHT=25>
Type following on command prompt
I hope this may help you.
rathorek - I think he's asking about a console app, not necessarily an applet, and I would assume an entry level CSC course will begin with console apps.
Lloyd9 - If you are using MSDOS only, put those commands in autoexec.bat, and restart your machine. They will load everytime the machine restarts so you don't have to run env.bat every time.
Alternatively, if you are running Windows rather than just MSDOS, you can set the environment variables without a batch file. Open the System widget in your control panel, click the advanced tab, and click the 'Environment Variables' button. You can use that interface to add JAVA_HOME and modify your path statement to include \bin.
Good luck, and feel free to PM me if you have any further install questions.
Where did you install java to, if its the c drive then I usually, do this in my console
If that doesnt work you may have a problem with your enviroment variables. Check your computers eviroment variables.
By jlopes151 in forum Database
Last Post: 11-21-2005, 04:32 AM
By Sandra in forum VB Classic
Last Post: 07-19-2002, 01:41 AM
Last Post: 05-29-2002, 01:38 PM
Last Post: 10-04-2000, 04:05 AM
By Mike Jewson in forum Java
Last Post: 06-01-2000, 12:32 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center