*
The moose likes Beginning Java and the fly likes Can't compile a simple program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can Watch "Can New topic
Author

Can't compile a simple program.

Ram Ganesan
Greenhorn

Joined: Nov 08, 2003
Posts: 6
Hello Gang,
I recently downloaded the latest version of J2SE SDK [c:/j2sdk1.4.2_02] and also updated the environmental variables and path as shown in thisweb page.
Then I wrote a simple "Hello World" program [c:/Hello.java] and tried to compile it from the command line. It just wouldn't. It says: 'javac' is not recognized as an internal or external command, operable program or batch file.
Is it something that I missed?
Karthik.
[ November 10, 2003: Message edited by: Karthik Ganesan ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

That web page neglects to mention that changes to environment variables aren't recognized by already-running programs. You have to opejn a brand new command window to see the new values.
If it still doesn't work, you may have made a typing error. The components of the PATH are separated by semicolons, with no spaces; and make sure the JAVA_HOME you set accurately reflects where your JDK was actually installed.


[Jess in Action][AskingGoodQuestions]
Ram Ganesan
Greenhorn

Joined: Nov 08, 2003
Posts: 6
Thanks for the reply.
One more thing.... Actually, I set up a user variable ('Path') with value ('C:\j2sdk1.4.2_02\bin')...and the program compiled!!
I want to know the basic difference b/w user variable and system variable.
P.S: The system variable ('Path') still has the %JAVA_HOME%\bin value as shown in the web page given above. Can I leave it as it is or remove it?
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
You could always comment it out and see how that affects your compilation and runtime. If it has no effect, you didn't need it, and you can leave it commented out.
Hope that helps!


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Ram Ganesan
Greenhorn

Joined: Nov 08, 2003
Posts: 6
Jeff,
I did as you said and it worked.
As for the program, being very small and simple, there wasn't much difference in compiling and running.
I still would like to know the difference b/w setting up path as user variable and system variable and also what, in general, environment variables are for.
Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127
difference b/w setting up path as user variable and system variable and also what, in general, environment variables are for

User variables are specific to a particular user (i.e. Under Windoze, if Joe is signed on, the variable is available to him but not if Sue is signed on. System variables are available regardless of who is signed on.
Environment variables are just that; they are there for the "environment" to work properly/easily. One of these environment variables is the PATH variable. For example:
PATH=c:\windows;c:\windows\system32 (and so on)
If you open a dos window and type 'notepad' (without the single quotes), it will open the notepad application, regardless of the directory you are in.
Ram Ganesan
Greenhorn

Joined: Nov 08, 2003
Posts: 6
Thanks Allen. Now I have a clear understanding about the environment variables.
 
wood burning stoves
 
subject: Can't compile a simple program.
 
Similar Threads
Running Java Programs from the command prompt
Package!
gcc on linux
i cannot run my JBoss program
Compiling hello world java class uing ANT on eclipse