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.
Code Java:
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.
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.
How can this spam be deleted?
Re: Noob, Helloworld stuff not working? Help?
Quote:
Originally Posted by
Norm
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?
Re: Noob, Helloworld stuff not working? Help?
NO, do NOT remove anything. Add the path to javac.exe to it separated by a ;
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?
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
Re: Noob, Helloworld stuff not working? Help?
Wooo it worked! Thanks for the advice.
Re: Noob, Helloworld stuff not working? Help?
You're welcome! Have fun programming. ;)