LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 09-15-2003, 03:09 PM   #1
bruce64
LQ Newbie
 
Registered: Jul 2003
Posts: 11

Rep: Reputation: 0
Setting the PATH for Java


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 -

export PATH=/usr/local/blackdown/j2sdk1.3.1/bin:$PATH

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 -

JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
PATH=$PATH:JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./

Any help is much appreciated! Thanks!

Bruce
 
Old 09-15-2003, 04:03 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
I think that path declarations etc. should be placed in ~/.bashrc rather than .bash_profile

Another thought...you must logout and back in for .bash_profile to be read again. Or just type:

. .bash_profile

('.' being the shortcut for 'source' ie: re-read)
 
Old 09-16-2003, 07:25 AM   #3
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
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
 
Old 09-16-2003, 07:49 PM   #4
bruce64
LQ Newbie
 
Registered: Jul 2003
Posts: 11

Original Poster
Rep: Reputation: 0
WIP

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?

Bp
 
Old 09-17-2003, 07:33 AM   #5
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
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.
 
Old 09-17-2003, 12:50 PM   #6
bruce64
LQ Newbie
 
Registered: Jul 2003
Posts: 11

Original Poster
Rep: Reputation: 0
Almost there!

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

export PATH
unset USERNAME

JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
PATH=/usr/local/blackdown/j2sdk1.3.1
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./

Again thank you for your time in this!

Bp
 
Old 09-17-2003, 01:10 PM   #7
marlaina1
Member
 
Registered: Jun 2001
Location: Houston
Distribution: CentOS 5.3
Posts: 139

Rep: Reputation: 15
**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?

Icon definition is at the bottom of the forum.

Last edited by marlaina1; 09-17-2003 at 01:26 PM.
 
Old 09-17-2003, 01:13 PM   #8
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
Try ordering your lines like this:

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:./

export PATH
export CLASSPATH
unset USERNAME

OR TRY THIS

PATH=$PATH:/sbin:$HOME/bin:/usr/local/blackdown/j2sdk1.3.1/bin:
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:./
JAVA_HOME=/usr/local/blackdown/j2sdk1.3.1
export PATH
export CLASSPATH
 
Old 09-22-2003, 11:16 AM   #9
bruce64
LQ Newbie
 
Registered: Jul 2003
Posts: 11

Original Poster
Rep: Reputation: 0
Thumbs up The news is good!

Hey Driedlinger,
I worked with both options you had posted. The second one worked like a charm! Thanks and take care!
 
Old 09-22-2003, 11:19 AM   #10
driedlinger
LQ Newbie
 
Registered: Aug 2003
Distribution: RH 7.3, 8, 9
Posts: 13

Rep: Reputation: 0
Glad you got going, best of luck to you!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Java Path gtkmike SUSE / openSUSE 1 05-09-2005 04:05 PM
Setting the path variable for Java Comp. lmellen Programming 1 06-27-2004 10:38 PM
setting path for java ahernaiz Programming 4 03-25-2003 04:30 PM
Setting Java path for root adcripps Linux - General 3 03-16-2002 02:36 PM
Setting Java path issues... jmizza Linux - Newbie 8 02-27-2002 08:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration