Hi, this is my first ever java programing assignment (example) yet following the instructions I have been given to configure javac in Command prompt is not working. I wrote the code in notepad and l am using a Windows XP machine. Who can help me? the code is:
package firstapplication;
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
The instructions l have been given are; (which i have followed).
Save the code in a file call HelloWorld.java in the directory c:\java_code\firstapplication
Open a Command Prompt window and change to the directory c:\java_code
Type javac firstapplication\HelloWorld.java and press enter (you should just get a blank line - no errors).
Type java firstapplication.HelloWorld and press enter. You should see Hello World.
CompilingConfiguring my Command prompt to compile my Hello world program.
Page 1 of 1
9 Replies - 917 Views - Last Post: 31 October 2008 - 09:32 AM
Replies To: Compiling
#2
Re: Compiling
Posted 05 April 2008 - 05:30 PM
Where's the problem? Can you not do one of the steps? You sdon't explicitly state what problem, if any, you are having...
#3
Re: Compiling
Posted 05 April 2008 - 06:06 PM
Have you gone to javas website and downloaded the JDK 6 Update 5?
#4
Re: Compiling
Posted 05 April 2008 - 09:12 PM
javahobby, on 5 Apr, 2008 - 01:04 PM, said:
Hi, this is my first ever java programing assignment (example) yet following the instructions I have been given to configure javac in Command prompt is not working. I wrote the code in notepad and l am using a Windows XP machine. Who can help me? the code is:
package firstapplication;
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
The instructions l have been given are; (which i have followed).
Save the code in a file call HelloWorld.java in the directory c:\java_code\firstapplication
Open a Command Prompt window and change to the directory c:\java_code
Type javac firstapplication\HelloWorld.java and press enter (you should just get a blank line - no errors).
Type java firstapplication.HelloWorld and press enter. You should see Hello World.
package firstapplication;
public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello World");
}
}
The instructions l have been given are; (which i have followed).
Save the code in a file call HelloWorld.java in the directory c:\java_code\firstapplication
Open a Command Prompt window and change to the directory c:\java_code
Type javac firstapplication\HelloWorld.java and press enter (you should just get a blank line - no errors).
Type java firstapplication.HelloWorld and press enter. You should see Hello World.
or to make it easier....
remove the package statement from jour Java program (you will have plenty of time to learn about that later)
then
cd c:\java_code\firstapplication
javac HelloWorld.java
java HelloWord
#5
Re: Compiling
Posted 05 April 2008 - 09:33 PM
I remember there was an environment variable in Windows XP that you must set in order to use javac from the command line.
However, since I can't remember what that was, I can't be of much help. Maybe it'll spark someone else's memory.
However, since I can't remember what that was, I can't be of much help. Maybe it'll spark someone else's memory.
#6
Re: Compiling
Posted 05 April 2008 - 09:49 PM
Yes after downloading the java development kit you head over to your computers properties, then click on the advanced tab and on that window look for Environment Variables. After clicking on Environment Variables look for a Variable named PATH on the top box(thats where I did it) if you do not have one click on new.
After clicking on new a window should appear, type in what I am showing you.
Variable name:PATH
Variable value:C:\Program Files\Java\jdk1.6.0_05\bin
^
|
|
sorry about the smiley face that part is 0 _ 0 without any spaces inbetween
You should only put in what I put for Variable value if you let the development kit install by default but if you did not then find the directory where you saved it in and type that in.
Heres a video if you need one : http://youtube.com/w...feature=related
At around 3:17 the man starts to explain how to do this.
After clicking on new a window should appear, type in what I am showing you.
Variable name:PATH
Variable value:C:\Program Files\Java\jdk1.6.0_05\bin
^
|
|
sorry about the smiley face that part is 0 _ 0 without any spaces inbetween
You should only put in what I put for Variable value if you let the development kit install by default but if you did not then find the directory where you saved it in and type that in.
Heres a video if you need one : http://youtube.com/w...feature=related
At around 3:17 the man starts to explain how to do this.
This post has been edited by Chacon-66: 05 April 2008 - 09:52 PM
#7
Re: Compiling
Posted 05 April 2008 - 09:51 PM
The Sun installation kit should do all that for you (if I remember well)
#8
Re: Compiling
Posted 05 April 2008 - 09:54 PM
I do not think it does, well maybe I just had bad luck when I was installing it =|.
#9
Re: Compiling
Posted 31 October 2008 - 09:05 AM
Just a quick question further about compiling...
What is the proper syntax to execute a compile from within a java program?
I need to call the compiler with some generated code and am having trouble finding an example of doing this from within the program.
Thanks,
Rita.
What is the proper syntax to execute a compile from within a java program?
I need to call the compiler with some generated code and am having trouble finding an example of doing this from within the program.
Thanks,
Rita.
#10
Re: Compiling
Posted 31 October 2008 - 09:32 AM
Quote
After clicking on new a window should appear, type in what I am showing you.
Variable name:PATH
Variable value:C:\Program Files\Java\jdk1.6.turn.gif5\bin
Variable name:PATH
Variable value:C:\Program Files\Java\jdk1.6.turn.gif5\bin
If there is already a Path variable name then add Variable value indicated above after everything else, preceded by a semicolon(
DO NOT change anything else as this could mess up other stuff on your computer already set up.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|