GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes running java from the command prompt window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "running java from the command prompt window" Watch "running java from the command prompt window" New topic
Author

running java from the command prompt window

Es Tresidder
Greenhorn

Joined: Aug 11, 2010
Posts: 16
Hi there

I've done a tiny bit of java from netbeans, but need to learn it to a much higher level. I've started the "Head First Java" book, which recommends that you do the exercises with a simple text editor and use the javac compiler. So I've been following the instructions here (http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html) for doing the "hello world" app with text files and from the command prompt. I can get into the java directory and see the file I've saved there, but when I type "javac HelloWorldApp.java" I get the following error message: ' javac' is not recognized as an internal or external command, operable program or batch file.

So what am I doing wrong?

Thanks in advance

Es
Francis Zabala
Ranch Hand

Joined: Aug 11, 2010
Posts: 30
Welcome to the Ranch Es Tresidder! I am a noobie myself but I got that problem to. Here's what you are going.

Go to Start -> Control Panel -> System -> "Advanced" Tab

Then click on the Environment Variables button, there will be two tables there, look at the bottom and find where it says "Path".

Select it, then click on edit. You should now see two text boxes one saying Variable Name and the other Variable value:

Here's what I have:
C:\PROGRA~1\Ticomm;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;C:\Program Files\Windows Imaging\;%HummPATH%;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;%JAD_HOME%;C:\Program Files\Java\jdk1.6.0_20\bin

The bold one is the one you need to add after your value. Please note that that is where my java is installed.

I have got the feeling that you are not using Windows XP... hehehe

By the way, after doing that, close all command prompts and open it up again.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14190
    
  20

Welcome to JavaRanch, Es and Francis.

Note that the problem that you get is one of the things mentioned in Common Problems (and Their Solutions) which is at the bottom of the tutorial page.

The JDK installation instructions (step 4) also explain how to set your PATH.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
GeeCON Prague 2014
 
subject: running java from the command prompt window