SlackwareThis Forum is for the discussion of Slackware Linux.
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.
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$
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:
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.
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:
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$
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.