Question:

Why wont my extremely simple java program run?

by  |  earlier

0 LIKES UnLike

I'm trying to learn java and I'm just starting to try and write some extremely simplistic code. The code I'm using is below:

public class TestApp

{

public static void main(String[] args)

{

System.out.println("Testing Testing Testing!!!");

}

}

The java file is called TestApp and is located on my desktop. When I bring up command prompt and enter "javac TestApp.java" it tells me there is no such internal command or batch or something. I can compile it by dragging the file into the javac executable though.

I then enter in command prompt "java TestApp" and it tells me theres an exception in thread main where there is no such class as TestApp.

Any suggestions?

 Tags:

   Report

4 ANSWERS


  1. Well, your first problem is, your OS doesn't seem to have its own java compiler.

    Your next problem is that you don't seem to be in the correct directory.  If TestApp is on the desktop, you need to say:

    cd desktop

    Then you can run it.


  2. I know that the problem is in your path variable.

    But none of this is important - nowadays, there is no reason to compile a java program yourself. You have eclipse to do it for you. Just download the IDE for java developers at: http://www.eclipse.org/downloads/downloa...

    There are also tutorials for java in eclipse.

  3. listen carefully..

    Then javac is present in ur jdk folder>bin

    to compile it ur path in promt should be in that folder...

    to make it available in all folders open notepad and write

    SET PATH=<BIN DIRECTORY EG C:\JDK1.2.2>BIN);

    SET CLASS=<LIB DIRECTORY EG C:\JDK1.2.2>LIB);

    save in the name "autoexec.bat"

    replace existing file and restrt ur computer

    next time when u save ur file.java save it in c:

    then in promp go in c: path and use javac...

    best of luck

  4. So first you need to configure your work environment.

    If you want to compile your java code from command prompt as you have mentioned then you need to set your javac into your path variable.

    Once you get your code compiled it will create a .class file for you.

    Then try java TestApp

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.