Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set classpath on Debian Linux

 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Linux/Unix forum.
 
Nart
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Before the path is exported, try:

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

Nart
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works when I set the Path like this!

I think the "$" here is very important.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic