|  | |
05-30-2006, 06:37 PM
|
#1 (permalink)
|
Master Techie Join Date: Mar 2004 Posts: 2,069
| java noob question Hello
I am trying to learn how to program in java.
i installed netbeans on my pc and i was wondering why i could not do a javac fro mthe command prompt? |
| |
05-30-2006, 08:12 PM
|
#2 (permalink)
|
Software Developer Join Date: Mar 2006 Location: Columbus, OH Posts: 569
| Did you install the JDK? |
| |
06-01-2006, 04:29 PM
|
#3 (permalink)
|
Master Techie Join Date: Mar 2004 Posts: 2,069
| thanks for the reply
by installing netbeans ide, have i not installed jdk,
i am running the java program in netbeans and they run ok, i thought that would mean that netbeans had automatically installed jdk to run java programs in the first place |
| |
06-01-2006, 05:02 PM
|
#4 (permalink)
|
Software Developer Join Date: Mar 2006 Location: Columbus, OH Posts: 569
| If the JDK is installed, you need to add the path to 'java' and 'javac' to your PATH environment variable. Otherwise, you'll have to add the path manually every time you call 'java' or 'javac' from the command line. For instance,
C:\Java\jdk1.5.0_02\bin\javac Class.java |
| |
06-02-2006, 04:07 PM
|
#5 (permalink)
|
Master Techie Join Date: Mar 2004 Posts: 2,069
| does installing netbeans mean that i have installed JDK?
how do i add java and javac to the PATH environment variable?
i have got 2 java folders on my c drive, the first one in porgram files and the second one in windows but neither have the jdk1.5.0_02 folder
the first one(progrm files/java) has j2re1.4.2_06 and jre1.5.0_01 folders and the second one(windows/java) has classes, packages and trustlib folder |
| |
06-03-2006, 12:18 AM
|
#6 (permalink)
|
Software Developer Join Date: Mar 2006 Location: Columbus, OH Posts: 569
| The Java Runtime Environment (JRE) does not include 'javac'. The JRE allows you to run java programs, but not compile them. 'javac' is in the JDK.
The JDK was previously referred to as the Java SDK. Maybe you have a j2sdk1.4.2_05 directory. If you do, 'javac' will be in the bin subdirectory. You could always just do a search for 'javac.exe' on your hard drive. |
| |
06-03-2006, 06:33 AM
|
#7 (permalink)
|
Master Techie Join Date: Mar 2004 Posts: 2,069
| thanks for the reply
i guess the runtime environment is the "java virtual machine"?
i found the javac.exe, it is present in the j2sdk1.4.2_04 directory,
will i have to compile all .java files from the j2sdk1.4.2_04/bin directory?
i guess intalling netbeans does not mean that i have installed the javac compiler, correct?
where can i add 'java' and 'javac' to the PATH environment variable. |
| |
06-03-2006, 06:09 PM
|
#8 (permalink)
|
Software Developer Join Date: Mar 2006 Location: Columbus, OH Posts: 569
| 1. In Windows XP, right-click on 'My Computer' and select 'Properties'.
2. Click the 'Advanced' tab.
3. Click the 'Environment Variables' button at the bottom.
4. Select the 'Path' system variable in the list and click the edit button.
5. Add the full path you listed above (C:\j2sdk1.4.2_04\bin). All the different paths should be separated by semicolons.
You might need to reboot afterward.
As far as Netbeans goes (I don't know much about it because I don't use it), I would think that it was responsible for the installation of the SDK you found on your hard drive. Maybe it didn't add the installation to your path variable. |
| |
06-03-2006, 07:24 PM
|
#9 (permalink)
|
Master Techie Join Date: Mar 2004 Posts: 2,069
| thanks for the reply
is the runtime environment the "java virtual machine"?
i can get javac to work, and my hello world program compiles fine, however when i try to execute it using java hello.class command i get the following error message
exception in thread "main" java.lang.NoClassDefFoundError: hello/class
can you tell me if i need to include something else
my hello world program contains the following java code
public class hello
{
public static void main ( String[] args )
{
System.out.println("Hello World");
}
}
the program ran fine in the netbeans ide |
| |
06-04-2006, 01:05 AM
|
#10 (permalink)
|
Software Developer Join Date: Mar 2006 Location: Columbus, OH Posts: 569
| Drop the '.class' extension when running from the command line. For example, you should type: And yes, the JVM is part of the JRE. |
| |  | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |