Perry Smith
Java Questions & Answers
Home /
Java Q & A Page 2 /
Java Q & A Archive Main Page
Question
Saturday, 31-Oct-98 22:28:00
208.206.3.117 writes:
I am just getting started with java for 21 days book. the very first program "hello world"
is causing me problems. I successfully create HelloWorld.class but when I run "java HelloWorld"
i get in return "Can't find class HelloWorld"
Here is the program
class HelloWorld
public static void main (String args[ ]) {
System.out.println("Hello World!");
}
}
any ideas?
Ted
Responses
Answer
Sunday, 01-Nov-98 21:25:59
171.212.204.158 writes:
I'm not fully familiar with the command line commands, but you'll have to compile your
HelloWorld.java code into HelloWorld.class. I believe (actually, I'm pretty sure) you use
javac.exe. So try going to the directory with the source code and type
"c:\java\bin\javac HelloWorld" and then, in that same dir "c:\java\bin\java HelloWorld".
Of course, you'll have to substitute the proper path name to the javac.exe and java.exe files.
MikeD
Re: Answer
Tuesday, 03-Nov-98 15:47:36
208.203.147.5 writes:
If you still have problems executing "java HelloWorld" from the directory where the
HelloWorld.class files exists, try adding the classpath setting.
For instance, if your class files reside in /home/mystuff/java, then try
"java -classpath /home/mystuff/java HelloWorld" (for Unix systems) or
"java -classpath c:\home\mystuff\java HelloWorld" (for Windows systems).
Brian
Home /
Java Q & A Page 2 /
Java Q & A Archive Main Page