Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Complier not working

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Complier not working

    Hi,

    As I am just starting out I have gone for the ubiquitous 'Hello World' programe as per the tutorials on line. I have downloaded the JDK programe and installed it but when I come to compile I get the following message:

    'javac' is not recognised as an internal or external command, operable program or batch file.

    Is there anything obvious I am doing wrong?

    Thanks,

    Ben


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Complier not working

    You're asking the command-line to look for javac in locations it can't find it, and the command-line is telling you that.

    There are a few ways to fix this (assuming you're using windows, linux is a bit different but not by much):
    1. Use the full path to java. This is a bit laborious, but works. For example:
    > "C:\Program Files\Java\jdk\bin\javac" helloworld

    2. Set your PATH environment variable to contain the path to the jdk bin folder. There are a few ways to do this, a quick google search should help you figure out how to do this. You'll have to logoff/restart to make sure that Windows updates the PATH variable. You can now call javac like this:
    > javac helloworld

    3. Navigate to the jdk bin folder. Now you can call javac without it's path, but you'll need to pass in the path to the java source code.
    > javac -sourcepath "C:\JavaSources\helloworld\" helloworld

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Complier not working

    Cool, I set the path in control panel so it worked and I got my 'Hello World' to compile and run.

    Now all I need to do is master the language. Are there any good beginner resources that you guys can suggest?

    Thanks,

    Ben

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Complier not working

    There are Sun/Oracle's Java tutorials. However, while these tutorials cover a lot, they're a little difficult to follow for beginners. Once you've got the Java syntax and lingo down, though, you should be able to whip through them and start writing your own programs in no time.

    The best way I found to learn Java was to take a class and then reinforce what I learned in class with other sources (such as here, the tutorials page I suggested, talking with the professor/fellow classmates, etc.).

Similar Threads

  1. [SOLVED] Buttons not working..
    By khms in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 2nd, 2010, 07:01 PM
  2. Cannot seem to get this working
    By OttawaGuy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 28th, 2010, 04:41 PM
  3. Boggle not working?
    By gandalf5166 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 6th, 2010, 11:53 AM
  4. Working with MAC .DMG files
    By mdv2000 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: January 21st, 2010, 12:31 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM