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 9 of 9

Thread: Noob, Helloworld stuff not working? Help?

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Noob, Helloworld stuff not working? Help?

    Just started learning some Java today, I downloaded the Java SE and Netbeans COBundle(JDK 5.0u22 and NB 6.7.1) and wrote this program in notepad.
    import javax.swing.*;
     
    public class HelloJava {
      public static void main( String[] args ) {
         JFrame frame = new JFrame( "Hello, Java!" );
         JLabel label = new JLabel("Hello, Java!", JLabel.CENTER );
         frame.getContentPane().add(label);
         frame.setSize( 300, 300 );
         frame.setVisible( true );
      }
    }

    I saved it as HelloJava.java, then opened command prompt and typed, C:\> javac HelloJava.java, to create the bytecode binary class file...I then received an error message stating 'javac' is not recognized as an internal or external command, operable program or batch file.

    Not sure what I'm doing wrong here.

    Any help would be greatly appreciated.
    Last edited by helloworld922; July 9th, 2010 at 01:11 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    The OS does not know where to find the javac command. You need to tell it where to look.
    Two ways:

    Find the location of the javac.exe file and use that to issue the javac command:
    c:\java\jdk1.2\bin\javac.exe ....


    Or add the location of the javac.exe file to the PATH environment variable:

    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and
    Click on the Environment variable's button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Its a stupid small text field so be careful.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Bdavis93 (July 7th, 2010)

  4. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default How can this spam be deleted?

    SPAM spam spam

  5. #4
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    Quote Originally Posted by Norm View Post
    The OS does not know where to find the javac command. You need to tell it where to look.
    Two ways:

    Find the location of the javac.exe file and use that to issue the javac command:
    c:\java\jdk1.2\bin\javac.exe ....


    Or add the location of the javac.exe file to the PATH environment variable:

    The PATH environment variable is set from the Settings | Control Panel | System panel.
    Select the Advanced tab and
    Click on the Environment variable's button.
    At the bottom in System Variables, find the PATH entry and click the Edit button
    Its a stupid small text field so be careful.
    I found the PATH entry and the text that is already there is this: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShel l\v1.0\

    Are you saying I should remove this text and replace it with the location of javac.exe?

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    NO, do NOT remove anything. Add the path to javac.exe to it separated by a ;

  7. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    Ok I did that and the javac command is functional, however, when I try to enter " javac HelloJava.java ", I'm getting this error message: error: cannot read: HelloJava.java
    1 error

    Any suggestions?

  8. #7
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    You have to make sure your in the files location. Type: cd C:/blahhhblahhh
    If you want to check to see if the file is in that directory type: dir

  9. #8
    Junior Member
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    Wooo it worked! Thanks for the advice.

  10. #9
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: Noob, Helloworld stuff not working? Help?

    You're welcome! Have fun programming.

Similar Threads

  1. helloworld noob
    By LostFury2012 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: July 14th, 2010, 06:29 AM
  2. HelloWorld
    By asbo in forum Member Introductions
    Replies: 1
    Last Post: March 22nd, 2010, 11:08 AM
  3. Need Help with my hmwk! Java noob!
    By ravij in forum Loops & Control Statements
    Replies: 4
    Last Post: October 7th, 2009, 01:02 AM
  4. VB can do stuff Java can`t ??
    By JFujy in forum Java Theory & Questions
    Replies: 2
    Last Post: September 22nd, 2009, 10:25 AM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM