Export Path for Java at Linux

while compiling at linux, i always need to export the PATH of java/bin then compile.
i don't want to export for every session i want it to write at PATH variable, somthing like write to bash profile or somthing and it will be valid after reboot the pc too, what is the way to do?
LVL 13
marchentAsked:
Who is Participating?
 
objectsCommented:
> i added this line to .bashrc at /home directory

not /home, in the home directory of the user that you are logging in as
0
 
objectsCommented:
add the export statement to your .bashrc file in home directory
0
 
marchentAuthor Commented:
how to add it?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
objectsCommented:
its just a text file. It gets executed when u start a new sheel so just add any commends you want run each time
in your case

export PATH=......
0
 
marchentAuthor Commented:
i did export, but when i exit the shell, and open new one, i have to write export once again, i don't want to do again and again.
0
 
objectsCommented:
add the export command to your .bashrc file. That gets executed automatically
0
 
marchentAuthor Commented:
i added this line to .bashrc at /home directory
export PATH=/usr/java/j2sdk1.4.2_15/bin/:$PATH
but now working.
0
 
ashesh17Commented:
Hi merchent
try this
there should be a file java.sh in /etc/profile.d/
put following in that file.

JAVA_HOME="path to ur java instalation" e.g. "/usr/java/jdk1.5.0_06"
CLASSPATH=.:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

now type echo $JAVA_HOME it should return the path as you set.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.