This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Set classpath on Debian Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Set classpath on Debian Linux" Watch "Set classpath on Debian Linux" New topic
Author

Set classpath on Debian Linux

Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 425
I've installed JDK1.5.
I try to set classpath use "export", but it only work on the current console.
When I restart or open another console, the JDK path can't be found.
I used to install JDK on RedHat Linux, there is a file /etc/profile. I can insert my Java Path here. But in Debian, the profile looks like this:


How to set Path in Debian? Thank you in advance.


To be or not to be. It's a question.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Moving this to the Linux/Unix forum.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Nart
Ranch Hand

Joined: May 28, 2002
Posts: 95
Hello,

Before the path is exported, try:

PATH=$PATH:/path/where/jdk5/is/installed/bin

Nart
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
One way to do this is to add a line at the end of /etc/profile to add more paths to the PATH variable. However, this is undesirable because it changes the PATH for every user. If you only have a single user on your machine, then it probably isn't too bad. A more elegant solution is to modify your user's .profile instead. Another option is to modify the rc script for the shell you use. For example, if you use bash, then you can modify .bashrc in your user's home directory to set the PATH the way you want it.

I hope this makes sense. If not, let me know and I will provide more details.

Layne


Java API Documentation
The Java Tutorial
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 425
It still can't work.
Now my .bashrc looks like this:


The result is
"louis@debian:~$ java
bash: java: command not found
"
Qunfeng Wang
Ranch Hand

Joined: Jan 28, 2005
Posts: 425
It works when I set the Path like this!

I think the "$" here is very important.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
In a bash script $ means to use the value of a variable. Without the $, the name is not evaluated. In other words, the name just stands for the literal characters. This means that on the left of the = sign, you typically want the variable name without the $, but on the right, you need the $ to get a variable's value rather than the exact characters you typed.

Also, the word "export" is important for the variable's value to last beyond the script's execution. Without the "export", the variable is "local" to the script, so to speak.

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set classpath on Debian Linux
 
Similar Threads
Default CLASSPATH for multi-user systems
environment variable in red hat 4.5.3
JDK, path problem in Linux
error starting up 2nd instance of tomcat
Eclipse on Debian Sarge