Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Java Classpath Problem


  • Please log in to reply
15 replies to this topic

#1 ussr1943

ussr1943

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 11:48 AM

hello again all :thumbsup:
i have decided to learn java.i went to the library got some books and i am on my way learning. wow this is a very useful language and i can't wait to start in. i needed to dl JDK which contains javac, the compiler program(just to run things off my machine first to learn the basics) and java which is the program that executes the .class file the javac compiler created. i have learned u must use the cmd prompt, and i am now at a loss. i have no clue about how to use it, but i tried a few times to do what this book says to run both apps.
it says C:\>javac Example.java
then C:\>java Example
..................................................
well thats all fine and dandy but when i start up cmd prompt it says immeadiately
C:\Documents and Settings\user>
... but i try anyways so i do this
C:\Documents and Settings\user>javac Example.java
and the window says 'javac is not recognized as an internal or an external command, operable program or batch file. i have no clue what to do now, and i have been playing with it for about 2 hours. any help would be appreciated.
thanks]



*crap now that i thought of it, i probably shouldda put this in the programming section*

Edited by groovicus, 15 August 2006 - 05:36 PM.

"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

BC AdBot (Login to Remove)

 


m

#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 12:40 PM

Allow me to move it for you. :thumbsup:

You are having a classic classpath issue... the software is installed, but the computer does not know that it is installed (if that makes sense). You need to add javac and java to your classpath. Adding it to your classpath is pretty easy, as long as you know where everything is... in other words, you need to know where javac and java are. They are going to be in your jdk/bin folder, so you will need to use explorer to figure out which jdk you downloaded. On my system, the path is C:\jdk1.5.0_06\bin.


Setting Paths:
If running XP, right click on my computer, then select properties. From there, click on the advanced tab, then environment variables. Just under the top text field, click on New. In the variable name, type in JAVA_HOME. In the Value, type in C:\jdk1.5.0_06, except use whichever jdk version that you installed on your system. Then click OK.

Now click on PATH in the top text field, and highlight PATH, then select edit. Add the following at the beginning (sometimes it will not work properly unless this is added first);%JAVA_HOME%\bin;. If there is already something on the path, make sure that there are no spaces following the semi-colon of the entry you just trped in, and the first character of the next entry. For instance:
%JAVA_HOME%\bin;%NETBEANS......
If there are any spaces, it will choke. Once you are done, click OK, then exit.

Open your command prompt, and type in java /?. If you have done this correctly, it should give you a list of commands. IF not, then there is an error in one of the path variables you entered. If it works for java, then try it with javac /?. It should also return a list of commands. Actually, if it works for one, it will work for the other since they are both in the same directory.

Let me know how that goes.

#3 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 03:48 PM

"Now click on PATH in the top text field, and highlight PATH, then select edit. Add the following at the beginning (sometimes it will not work properly unless this is added first);%JAVA_HOME%\bin;. If there is already something on the path, make sure that there are no spaces following the semi-colon of the entry you just trped in, and the first character of the next entry. For instance:
%JAVA_HOME%\bin;%NETBEANS......
If there are any spaces, it will choke. Once you are done, click OK, then exit."
i'm at a loss, i donot see where it says path in the top text field.
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 04:01 PM

Are you using Windows XP?

EDIT: Actually, it doesn't matter. I will assume that since you did not find a path variable, then one has not been created. So instead, you would create a new variable named PATH. So just under the first text box, click new, then type in PATH for the variable name.Then in the value box, enter %JAVA_HOME%\bin;.

That should do it.

#5 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 04:14 PM

yes i have windows xp, and i did the first part of what u said but the next part i cant find where it says path where u said.

Edited by ussr1943, 15 August 2006 - 04:15 PM.

"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 04:17 PM

lol.. I just edited my previous post.....

#7 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 04:20 PM

not wuite working, when i do the cmd for java it comes up with stuuf
but not for javac
i did what u said in last post.

have to go eat i will be back in a lil bit.

Edited by ussr1943, 15 August 2006 - 04:21 PM.

"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 04:23 PM

Ok, so we are halfway there then. Open explorer and look in the jdk/bin folder. See if javac exists in there.

#9 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 04:59 PM

yep it exists and is in the right folder.
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#10 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 05:07 PM

What message are you gettting when you type in javac /?.

#11 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 05:09 PM

'javac is not recognized as an internal or an external command, operable program or batch file
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#12 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 05:13 PM

What is the full path name to your JDK/bin folder?

#13 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 05:15 PM

C:\Program Files\Java\jdk1.5.0_05\bin
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#14 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:54 AM

Posted 15 August 2006 - 05:23 PM

Ok, so when you set you JAVA_HOME variable, did you set it to C:\Program Files\Java\jdk1.5.0_05\bin?

#15 ussr1943

ussr1943
  • Topic Starter

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:04:54 AM

Posted 15 August 2006 - 05:25 PM

yep

****

ok i think i found the problem and its fixed, i noticed for the PATH variable it said C:\Program Files\Java\jdk1.5.0_05\bin\bin
so i got rid of the bin on %JAVA_HOME%\bin;
to makes %JAVA_HOME%
and it shows the path now as C:\Program Files\Java\jdk1.5.0_05\bin
and i typed in both java and javac and they both work now. thanks for your help.




**Mod edit** combined posts~g
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users