Compiling

Configuring my Command prompt to compile my Hello world program.

Page 1 of 1

9 Replies - 1034 Views - Last Post: 31 October 2008 - 09:32 AM Rate Topic: -----

#1 javahobby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-April 08

Compiling

Post icon  Posted 05 April 2008 - 01:04 PM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: Compiling

#2 KYA  Icon User is online

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3093
  • View blog
  • Posts: 19,139
  • Joined: 14-September 07

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...
Was This Post Helpful? 0
  • +
  • -

#3 Chacon-66  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 03-April 08

Re: Compiling

Posted 05 April 2008 - 06:06 PM

Have you gone to javas website and downloaded the JDK 6 Update 5?
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Compiling

Posted 05 April 2008 - 09:12 PM

View Postjavahobby, 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.


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
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5182
  • View blog
  • Posts: 26,880
  • Joined: 10-May 07

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.
Was This Post Helpful? 0
  • +
  • -

#6 Chacon-66  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 03-April 08

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.

This post has been edited by Chacon-66: 05 April 2008 - 09:52 PM

Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Compiling

Posted 05 April 2008 - 09:51 PM

The Sun installation kit should do all that for you (if I remember well)
Was This Post Helpful? 0
  • +
  • -

#8 Chacon-66  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 03-April 08

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 =|.
Was This Post Helpful? 0
  • +
  • -

#9 ritab68  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 06-October 07

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.
Was This Post Helpful? 0
  • +
  • -

#10 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

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


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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1