-   Programming (
-   -   Java Classpath... dear god... (

Jaster 01-27-2005 10:32 PM

Java Classpath... dear god...
Ok, I need help with this on windows right now (and I will then try to figure it out on linux and coe back here and ask when I fail ^_^). Ok, I have java installed on my windows partition and it works great. I now have a .jar file (C:\g5jdk\generation5.jar) that I want to add to the java classpath so I can use all the packages and classes in it. So, I went to the enviroment variables section of System in the Control Panel. There was no CLASSPATH variable so a made a new one and set it to ".;C:\g5jdk\generation5.jar" and saved it. Now I try to run a program that imports classes and packages that should be in said .jar file and it won't compile (no class def found). What am I doing wrong here? Any help welcome. Thanks.

drisay 01-28-2005 09:13 AM

did you restart your command prompt? the new settings won't take effect until your next session.

darkRoom 01-28-2005 11:01 AM

ha, ha i like your thread title ;)

Sounds like the classpath isn't a problem now since you can use javac.

To compile the program i guess you are trying 'javac' and you are in or give a path to where the .java file is. If not post back with more details

Azzath 02-02-2005 02:25 PM

Hello and thanking everyone helping out there!! You guys have no idea how much of appriciation me and my firend's got for everyone's whose helping out in this site!!
I need to know if anyone could tell me a way to compile my java programs without giving the javac
i have just installed java. And its a bit of time taking by giving the whole path like i had typed above. Could someone give me an idea to straight forwardly make it to understand the "javac" and "java" commands from the command prompt....i.e
azzath@d_hyper java_programs]$ javac
bash: javac: command not found
without getting this error message...:)
Thanks in advance.

.................................................................................................... ...........................................
anyone who is trying to install java then hopefully this site would help i guess, cuz i got help from this site.

Teoryn 02-02-2005 06:34 PM

If you add a path to the classpath it will always check there. What I did in windows was put '.' in my classpath, then I could navigate to a folder and run the code from there.

Azzath 02-02-2005 07:10 PM

Thank you buddy...
But thats wha i'm trying to do. But i am not sure how to fit in..
export PATH=$PATH:/usr/java/jdk*/bin/ into export PATH=$PATH:/usr/games(which is the "profile" script in the /etc directory)
If yu know anything about it please let me know.
So is that your site..
It looks cool..i havent surfed verymuch into it...but sould be very educational.
Thanx again mate.


drisay 02-03-2005 07:54 AM

just replace "export PATH=$PATH:/usr/games" with "export PATH=$PATH:/usr/games:/usr/java/j2sdk1.4.2_07/bin" in your profile script.

kees-jan 02-03-2005 09:53 AM

Jaster: Are you using an ide? It might be messing up your classpath.



codestorm 02-03-2005 06:04 PM

Ok, given you're doing this for Windows.
(Instructions based on Winblows 2000)
Right-click on "My Computer", select Properties.
Advanced tab, New button in top "User variables for ..." section.
Variable Name: JAVA_HOME
Variable Value: <path to your java install>
e.g. c:\j2sdk1.4.2_04
(not directly to it's bin directory, or anything)
Also it probably couldn't hurt to add it to the PATH variable:
In bottom "System variables" section, find Path in list and press Edit button.
Append path above, with bin dir added, prepended by a ; to Value.
e.g. ;c:\j2sdk1.4.2_04\bin\
Sorry, sure you didn't need these baby steps, but avoids the potential for confusion.

Azzath 02-03-2005 06:39 PM

Drisay thank you....
I did edit the /etc/profile file and i still cannot get the javac command to work..
the edited part is as follows..

export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin (OR does it need double quotes such as
export PATH="$PATH:/usr/java/j2sdk1.4.2_07/bin " amd dows the bin finishes with /bin/)

but still the javac is not recognised....

whats the difference in editing as

export PATH=$PATH:/usr/java/sdk*/bin ( which i saw in this site )
i can always call the path eg:/user/java/j2sdk1.4.2_07/bin/javac

but its always a pain to type in the path...

could some one please tell me if this is the right file to edit which is profile (but in the above site mensioned the person told to edit the /etc/profile.d/ file ( where there wasnt such a file). But i still created a file named and just gave the line export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin. I know this is not right. I'm sorry, i am not a programmer, but keen in learning java.
But i would like to solve this problem and would some one tell me what might be going wrong ?

kees-jan 02-04-2005 02:36 AM


Let's see... The PATH environment variable contains a list of directories that are searched whenever you type a command. You say that you get "command not found" if you type "javac". So could you please type

echo $PATH
and post the output? Because after all the changes you have made, there should be some differences :-).

Which shell are you using anyway? Please type

echo $SHELL
and post the output. If you are using bash (which is the default), then whenever you login, /etc/profile is read and executed. Therefore, if you change the content of /etc/profile (i.e. add commands that change the path), then changes should be visible at your next login. Did you log out and back in after changing?

Sometimes, /etc/profile contains a piece of code that reads all files in /etc/profile.d, and executes them as well. This is distribution dependent. If your /etc/profile indeed has this piece of code, then there should be no difference between editing /etc/profile, and editing any file in /etc/profile.d. But, as said, this depends on this piece of code in /etc/profile.

By typing "export PATH=", you can give the path an entirely new value. $PATH gives you the current (or old value), so

export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin
basically says "The new value of my PATH should be equal to the old value, plus some stuff concatenated".

If you have only one j2sdk directory, then you can use a * to save you some typing. So, the above could also be written as

export PATH=$PATH:/usr/java/j2sdk*/bin
If you have only one directory, then this is convenient, because it will figure out the version stuff by itself. If you have several, then this will not work, and you'll be able to use neither. Therefore, I generally do not recommend it.

Quotes can be used for pathnames that contain spaces and some other weird characters. Even so, you probably shouldn't use spaces and weird characters in pathnames anyway. Furthermore, when using quotes, the * trick above doesn't work anymore.

Good luck with your efforts,



jlliagre 02-04-2005 02:55 AM


export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin:

Azzath 02-04-2005 06:18 AM

Thanking you kees-jan and the rest who had helped me out with my roblem,

Kees: i initially thought that logging out means come out of "su", then when i swiched my computer on this morning the javac command worked :)
First thing i did was reading ur message and when i went to play with it again by doing an echo $PATH it showed me the path as below, then i tried the javac command and it listed javac and java and it worked well Buddy.

[azzath@d_hyper azzath]$ echo $PATH
[azzath@d_hyper azzath]$ echo $SHELL
I really appreciate for the time and effort you took to explain me all this. Thanking you again.

And also i would like to thank the senior member jlliagre, for his long time effort.
Take care guys.

Regards Azzath.

kees-jan 02-04-2005 06:44 AM


[azzath@d_hyper azzath]$ echo $PATH
Ideally, you should remove the two entries with stars in them "/user/java/jdk*/bin/", because they don't do anything but confuse things. The entry "/usr/java/j2sdk1.4.2_07/bin" is sufficient and should remain.



Azzath 02-04-2005 08:56 PM

Thank you kees-jan,
But would you please tell me which file should i open to delete that entry in the path?

All times are GMT -5. The time now is 07:19 PM.