Steps to build a java program
1) create a directory (C:\projects)
2) open notepad, or other editor, and create a java class
public class HelloWorld {
public static void main(String [] args) {
System.out.println("Hello World!");
}
}
3) save the above file as HelloWorld.java (case sensitive)
4) open a command window
5) cd to \projects (or what ever dir you saved HelloWorld.java in)
6) type javac HelloWorld.java
7) type java HelloWorld
Ta Da! you have just run your first java program
If anything doesn't work, post the entire error message here.
~Tim
Edit: Fixed typo
> C:\ProgramFiles\JDK1.xxx...\..\bin should be in the path
Yes. And we know it is in this case because of reply 15.
> rt.jar & C:\Project should be in classpath
Why?
Don't mess with the CLASSPATH variable. If one is not already defined (as
appears to be the case with the OP), then don't create one. If one is defined (because
of quicktime or whatever), leave it alone. The Java tools don't require any
special CLASSPATH setting.
Instead compile and run withjavac -cp . HelloJava.java
java -cp . HelloJava
hey i know that this is kind of an old subject but i have been having similar problems i think i may have even bought the same book. but when i did what some one else told me to do it came back at me with "javac" is not reconized as an internal or external command, operable program or batch file.
The error message you got is different - indicating that this is quite a
different problem.
The error message you got is the one given by the Windows operating
system when you ask it to execute a command, but it cannot find the
executable file (program) that the command refers to.
In your case you attempted the command "javac", but Windows does not
know where the "javac.exe" file is on your system.
The solution is described here:
http://java.sun.com/docs/books/tutorial/getStarted/problems/index.html
and in the page that is linked from there:
http://java.sun.com/javase/6/webnotes/install/jdk/install-windows.html#Environment
If you get stuck start a new thread because it really is a new problem.