Maneesh Godbole wrote:James,
Welcome to the Ranch.
java HelloWorldApp will run the application. To compile, you need to run javac HelloWorldApp.java
Yes i have already compiled it using the javac HelloWorldApp.java and it made the .class file this is the error i get when i try to run this file.
I dont understand the cp? Where am I pointing it to?
Edit ok after further reading thanks to your guys suggestions I got it... Now here
Now enter java HelloWorldApp again. If the program works now, you'll have to change your CLASSPATH variable. To set this variable, consult the section in the JDK 6 installation instructions. The CLASSPATH variable is set in the same manner.
So i need to set the CLASSPATH variable somewhere else to avoid this problem in the future?
Please use copy-and-paste to post the error messages, not screen capture. Click the top left icon on the command window, then edit, then mark, then highlight the text with the mouse, then enter to copy to clipboard. It is much easier to read.
When you compiled the file, with
I presume you got no error messages? If the file compiles, nothing happens; you only get error messages if something goes wrong. Try the "dir" instruction to see where the .class file is.
If it is in your current directory, try the earlier suggestion of
java -cp . HelloWorldApp
Remember the java tool doesn't require extensions.
If that doesn't work, post the code you are compiling.
You should not normally set a system classpath, but some applications eg QuickTime, set a system classpath which can b*gg*r up your normal Java settings. If that is the case add .; to the beginning of the system classpath. You can have several .s in your classpath; I have tried it, and it doesn't seem to do any harm.
Joined: Feb 25, 2010
thank you guys for all the help now I can finally start working through my head first java book