Q&A: Java Help – My First Program?

Question by Ozzie: Java Help – My First Program?
Hello all,

I’m having a little trouble with Java. I’m taking a online course, so I’m having to just figure this out. I installed Java JDK 6 Update 6 with Java EE. From what I gather I’m suppose to write my programs in notebad (Textpad) and then compile them from command prompt. This is where I’m having trouble figuring out what to do, or if I’m even running Java itself properly (sort of lost). I wrote a simple program and named it FirstProgram.java

public class FirstProgram
{
// main method begins execution of Java application
public static void main( String args [] )
{
System.outprintln( “Welcome to Java Programming!”);
}

}

I can not figure out how to compile it or make it run to see if it works.

Any help would be great.

Running Vista by the way.

Best answer:

Answer by rollandb1
find out what directory javac is in and then copy your file to that directory then goto cmd and change to the directory where javac is and then you can compile it. also it has been along time since i have programmed java but i think that your System.Out.Println is wrong.
i would recommend doing a search on yahoo or goolge for environment variables you can add the path to the javac file and then you can run it from any directory till you do this though you have to run all you programs from the directory that contains javac

Know better? Leave your own answer in the comments!

You can leave a response, or trackback from your own site.

2 Responses to “Q&A: Java Help – My First Program?”

  1. Caoimhin B says:

    First of all, you really didn’t need the JavaEE version, the standard JDK would have been sufficient.

    You need to open a command prompt. In vista, I think you do this by clicking the start menu and type cmd in the search box at the bottom of the start menu.

    In the command prompt do to the directory which has FirstProgram.java

    e.g.:
    cd javamyprograms

    Once there type the following:
    javac FirstProgram.java

    If if compiles successfully, which it looks like it would, the javac command will produce a file called FirstProgram.class. To run it type:

    java FirstProgram

    Notice how the .class is omitted.
    Hope that helps

  2. Divineforge says:

    well… step by step… as follow

    1. make correction from “System.outprintln” to “System.out.println ”

    2. at command problem, use command “dir” or “cd” change into the directory where u save u FirstProgram.java

    3. type “javac FirstProgram.java” in command, and enter.(if no message shows up mean compilation successful., otherwise, debug it)

    4. to run it, just type “java FirstProgram”

    that’s it. have a nice day.

Leave a Reply

You must be logged in to post a comment.

Powered by Yahoo! Answers