Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble running first application

 
Brendon Gehring
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Sanjaya Sugiarto
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Brendon Gehring
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic