Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Trouble running first application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trouble running first application" Watch "Trouble running first application" New topic
Author

Trouble running first application

Brendon Gehring
Greenhorn

Joined: Aug 24, 2006
Posts: 2
I've tried to follow the directions for running the HelloWorldApp, but seem to be doing something wrong somewhere.

I create the text file using Notepad, saving it as "HelloWorldApp.java".

I then change the current directory in the Command Prompt to the file containing HelloWorldApp.java by typing "cd c:\Java Practice" (without the quotes). This seems to work.

I then try to compile the code by typing "javac HelloWorldApp.java" to the command line (again, without the quotes), and get the following error: 'javac' is not recognized as an internal or external command, operable program or batch file.

I have a j2sdk1.4.2_12 folder directly on my C drive with the bin and jre files inside that. The bin folder contains the executable, javac.exe. I think I haven't told the Command Prompt where javac is located some how, but don't know the missing step.

Apologies for the low level of the question. Have just been banging my head against the computer for a day now...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

5. Update the PATH variable

http://java.sun.com/j2se/1.5.0/install-windows.html

(this is for 1.5, but the procedure is the same for 1.4.2)


[My Blog]
All roads lead to JavaRanch
Sanjaya Sugiarto
Ranch Hand

Joined: Mar 25, 2004
Posts: 229
you should configure your system variables.

in windows:
start >> Settings >> Control Panel >> System >> Advanced >> Environment Variables

Search for variable 'Path' than add (using ';' as separator):
C:\folder_where_you_install_jdk\bin (e.g C:\j2sdk1.4.2_12\bin)

Add new variable JAVA_HOME and as value:
C:\folder_where_you_install_jdk (e.g C:\j2sdk1.4.2_12)

(you can skip this step, it's just for checking: start >> run >> type 'cmd' without quote >> and type 'java -version' without quote. If you get something like "java version 1.4.2_12 blablabla" than you have done right with your system variables)

Back to the system variables:
Add new variable CLASSPATH and as value:
your_project_path (in your case the folder path where you saved HelloWorldApp.java)


<a href="http://www.wi.hs-furtwangen.de" target="_blank" rel="nofollow">Business Information Technology - Hochschule Furtwangen University, Germany</a>
Brendon Gehring
Greenhorn

Joined: Aug 24, 2006
Posts: 2
Thank you Satou for the great link. It provides a lot of great information.

And thank you Sanjaya for the very clear, step by step directions. They really made it easy, and all worked as advertised.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trouble running first application