Connecting Tech Pros Worldwide Forums | Help | Site Map

infamous hello world

Newbie
 
Join Date: Dec 2007
Posts: 26
#1: Jun 13 '08
scribes

I am trying to run the infamous hello world script in java and when i compile in dos prompt using the folling code "javac helloworld.java" i get the error message
javac is not recognised as an internal or external command, operable program or batch file. I have saved the script in this directory: c:\java\ ...

thanks in advance

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Jun 13 '08

re: infamous hello world


That was a message from your shell (command line interpreter); it can't find
anything named 'javac.exe'. Set your PATH variable to the directory where your
javac.exe is stored. This has nothing to do with java.

kind regards,

Jos
Newbie
 
Join Date: Dec 2007
Posts: 26
#3: Jun 13 '08

re: infamous hello world


hi this is where java is so how do i set the path

C:\Program Files\java\jre1.6.0_06\bin
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

hi this is where java is so how do i set the path

C:\Program Files\java\jre1.6.0_06\bin

Nope, that's not where your PATH variable should point to.That is not the location
where your 'javac.exe' command is stored (note the trailing 'c').

Move to your jdk directory where you will find both 'java' and 'javac' in its bin
directory. The jdk directory is stored next to this jre directory.

kind regards,

Jos
Newbie
 
Join Date: Dec 2007
Posts: 26
#5: Jun 13 '08

re: infamous hello world


hi i only have the jre directory and no jkd

how do i proceed now

regards
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#6: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

hi i only have the jre directory and no jkd

how do i proceed now

regards

If you don't have a jdk (Java Development Kit) you don't have javac nor the other
tools. Better get rid of this jre and download a complete jdk (plus a bundled jre)
from this link.

You need JDK 6 update 6 (the second paragraph on that page).

kind regards,

Jos
Needs Regular Fix
 
Join Date: Aug 2007
Posts: 283
#7: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

hi i only have the jre directory and no jkd

how do i proceed now

regards

Proceed by installing the latest copy of jdk and jre from the Sun's official site and read the instructions on how to set up Java on the local machine.

Only jre wont do, you need both the jdk and jre to run.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#8: Jun 13 '08

re: infamous hello world


ps. also have a look at our little Java Articles Index page; it contains
links to the entire documentation of your Java SE installation; ready for download
(hint hint) and some more useful stuff.

kind regards,

Jos
Newbie
 
Join Date: Dec 2007
Posts: 26
#9: Jun 13 '08

re: infamous hello world


i have down loaded the jdk and installed...how do i set the directory to point to where the java c is i on a windows machine...
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#10: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

i have down loaded the jdk and installed...how do i set the directory to point to where the java c is i on a windows machine...

Control Panel > System > Advanced > Environment Variables.

kind regards,

Jos
Newbie
 
Join Date: Dec 2007
Posts: 26
#11: Jun 13 '08

re: infamous hello world


do i paste this on the C:\Program Files\java\jdk1.6.0_06\bin on the user variables or the system variables
Needs Regular Fix
 
Join Date: Aug 2007
Posts: 283
#12: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

do i paste this on the C:\Program Files\java\jdk1.6.0_06\bin on the user variables or the system variables

Read the installation manuals from where you installed Java, also the articles jos posted. Alternately google for setting classpath for java.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#13: Jun 13 '08

re: infamous hello world


Quote:

Originally Posted by change

do i paste this on the C:\Program Files\java\jdk1.6.0_06\bin on the user variables or the system variables

I took the coward's approach: I checked which one of them already had a PATH
variable defined; there I added that jdk directory. Otherwise simply add it to the
system's part.

kind regards,

Jos
Site Addict
 
Join Date: Nov 2007
Location: Cebu City, Philippines
Posts: 514
#14: Jun 14 '08

re: infamous hello world


Quote:

Originally Posted by change

i have down loaded the jdk and installed...how do i set the directory to point to where the java c is i on a windows machine...

i think the installer already programmed to add a classpath in the System variables in Windows.... @ jdk 6.x version
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#15: Jun 14 '08

re: infamous hello world


Quote:

Originally Posted by sukatoa

i think the installer already programmed to add a classpath in the System variables in Windows.... @ jdk 6.x version

Not that I know of; if I remember well I always have to set my PATH variable to
the appropriate directory manually.

kind regards,

Jos
Reply