LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-24-2011, 09:58 AM   #1
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Rep: Reputation: 24
set java home path


I installed an editor that works fine for root, but for user produces this error.
Code:
bash-4.1$ jedit &
[1] 2046
bash-4.1$ Warning: $JAVA_HOME environment variable not set! Consider setting it.
          Attempting to locate java...
Failed to locate the java virtual machine! Bailing...
Root has
Code:
root@a:~# which java
/usr/lib/java/bin/java
root@a:~#
whereas user has
Code:
bash-4.1$ which java
which: no java in (/usr/local/bin:/bin:/usr/bin)
bash-4.1$
Following instructions given in http://www.cyberciti.biz/faq/linux-u...path-variable/ to set this variable globally, I added the line
export PATH=$PATH:/usr/lib/java/bin/java
to /etc/profile, restarted and got this result
Code:
bash-4.1$ jedit &
[1] 3425
bash-4.1$ Warning: $JAVA_HOME environment variable not set! Consider setting it.
          Attempting to locate java...
Failed to locate the java virtual machine! Bailing...

[1]+  Exit 1                  jedit
bash-4.1$ which java
which: no java in (/usr/local/bin:/bin:/usr/bin)
bash-4.1$
How does one set this thing?
 
Old 04-24-2011, 10:15 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You need to set the JAVA_HOME environment variable, as the message suggests.

export JAVA_HOME=/usr/lib/java

should do it.
 
Old 04-24-2011, 11:39 AM   #3
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
I'm pretty sure, looking at your prompt, that you are in some kind of X terminal, and that you're not launching it with a login shell. That's why JAVA_HOME is not set, when it should have been set from one of the profile initialization files in /etc/profile.d/.

If you use, say, xterm, launch it as "xterm -ls", and the problem would be gone. If you don't want to use "-ls" every time, you can set the loginShell property from the X resources file. Example:

Code:
echo 'xterm*loginShell: true' >>~/.Xresources
xrdb -merge ~/.Xresources
And every time you launch xterm from then on, it will use a login shell and you should have JAVA_HOME set properly.
 
Old 04-24-2011, 11:46 AM   #4
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,781

Rep: Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459Reputation: 1459
deleted

Last edited by Petri Kaukasoina; 04-24-2011 at 11:48 AM. Reason: rg3 was faster
 
Old 04-24-2011, 01:05 PM   #5
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by Nylex View Post
You need to set the JAVA_HOME environment variable, as the message suggests.

export JAVA_HOME=/usr/lib/java

should do it.
Thank you for your help. That works if I issue it in the terminal immediately before I start jedit, but in /etc/profile it has no effect. Is there some other script I should put it in. I think the website I used as the original reference mentioned .bashrc (or something like), but slackware doesn't have that file.
 
Old 04-24-2011, 01:25 PM   #6
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by rg3 View Post
I'm pretty sure, looking at your prompt, that you are in some kind of X terminal, and that you're not launching it with a login shell. That's why JAVA_HOME is not set, when it should have been set from one of the profile initialization files in /etc/profile.d/.

If you use, say, xterm, launch it as "xterm -ls", and the problem would be gone. If you don't want to use "-ls" every time, you can set the loginShell property from the X resources file. Example:

Code:
echo 'xterm*loginShell: true' >>~/.Xresources
xrdb -merge ~/.Xresources
And every time you launch xterm from then on, it will use a login shell and you should have JAVA_HOME set properly.
Correct, I startx in /etc/rc.d/rc.local. As user, I did as you recommended for both xterm and terminal (I'm using xfce), but no luck. I rebooted and did the following in Terminal when xfce opened up.
Code:
bash-4.1$ cat ~/.Xresources
xterm*loginShell: true
terminal*loginShell: true
bash-4.1$ jedit &
[1] 2071
bash-4.1$ Warning: $JAVA_HOME environment variable not set! Consider setting it.
          Attempting to locate java...
Failed to locate the java virtual machine! Bailing...

[1]+  Exit 1                  jedit
bash-4.1$
 
Old 04-24-2011, 01:56 PM   #7
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
If you're starting X from rc.local then I can only assume that you aren't getting a full login shell for your user in the first place, and therefore any environment variables set in /etc/profile.d/*.sh aren't being inherited. JAVA_HOME and PATH are adjusted in /etc/profile.d/jre.sh (so make sure that's executable), but if you never start a login shell then it won't be run. You could either take steps to ensure that a login shell is being run (ie make sure your terminal is run as a login shell as suggested by rg3) or you could add
Code:
. /etc/profile
to your .bashrc (create the file if it doesn't exist). Usually I would discourage launching terminals as login shells because it ends up duplicating information in inherited variables, but if a login shell is never launched to begin with then obviously this isn't the case.
 
1 members found this post helpful.
Old 04-24-2011, 02:30 PM   #8
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch, Lubuntu 18.04 OpenSUSE Leap 15.x
Posts: 518

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by T3slider View Post
...you could add
Code:
. /etc/profile
to your .bashrc (create the file if it doesn't exist).
Many thanks, that solved the problem, and also lets me continue bypassing the login, as I prefer.
 
  


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
set up java_home path in /home/user/.bashrc but use path in /usr/lib/java vitalstrike82 Slackware 4 01-13-2009 11:25 PM
how to set up path,classpath,catalina home for java in fedora -9 vicky7038 Linux - Software 1 08-19-2008 08:41 AM
Ubuntu 7.10 64bit - how to set java path to/redirect java to libjvm.so ? Thane Ubuntu 1 03-25-2008 05:52 PM
java home/path konfigure SUSE / openSUSE 4 07-02-2007 09:44 PM
Cannot set the path for java jgoggel Programming 2 07-23-2004 06:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:40 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