Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Good afternoon everyone,
I have installed Java and the problem I am having is setting the path in my .bash_profile. As root I exported the path in the dir with the following line -
After I enter that line I check with "which java" and it returns the correct path. However when I try to include this in my .bash_profile the path is not recognised. I am using the following lines to put in my profile -
You may also want to put your $PATH info in the .bashrc file as the variables in the .bashrc file are exported from shell to shell being when you spawn a new shell these variables get kept in the new shell.
You may also want to make sure you include a "$" in any variables you use..ie your JAVA_HOME in you path did not have a $ to indicate it was a variable.
PATH=$PATH:$JAVA_HOME/bin
Hey guys,
I tried putting the path in my .bashrc however I didn't have much luck there. I also noticed that when I log in as regular user I can use the export command and get Java to run my programs. I guess I'm not too put out if I have to do that but I will try two more things with bash files then I'm going to throw in the towel for now. Again thanks for the tips!
**One quick question for the moderator**
Why does my envelope have a bullet point on it? Have I put this question in the wrong forum?
you are sure that you are using your JAVA_HOME variable correctly.
You had :
JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
PATH=$PATH:JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./
Notice your PATH statement, the JAVA_HOME needs to be $JAVA_HOME. If this is not the case, type this command:
env
or
env | grep j2sdk (this will only display the lines with "j2sdk" in it if it is there.)
This will dump out all your environment variables, you should see your path and your java_home variables, if you don't then you are not setting them correctly in your profile or .bashrc.
review what was posted earlier and make sure all your spellings are correct, I have been bitten by that before.
Hey Driedlinger,
I rechecked the spelling and the misspelling was in my initial post. In my .bash_profile I had it correct with the $ in front of Java_Home. However I noticed that I had commented out the PATH line in the following
JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
#PATH=/usr/local/blackdown/j2sdk1.3.1 -- this line was commented out
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./
Now when I save my changes another problem arises. Basic shell commands are no longer recognised. Below is the .bash_profile in its entirety. I'm guessing the first Path statement is conflicting with the path statement for Java?
PATH=$PATH:/sbin:$HOME/bin
JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
#Take the below line out it is messing you up, it is setting your path to the /usr/local/blackdown/j2sdk1.3.1 #PATH=/usr/local/blackdown/j2sdk1.3.1
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.