LinuxQuestions.org
Help answer threads with 0 replies.
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 06-06-2009, 02:59 AM   #1
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129
Blog Entries: 1

Rep: Reputation: 15
java "command not found"


On a fresh and full install of Slack12.2 I get "command not found" every time I type in java on a terminal. Is there a way of fixing this?
 
Old 06-06-2009, 03:07 AM   #2
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
You could verify if you have installed jre from /slackware/l or jdk from /extra. If you have one of them installed (I don't know if you can have both installed at the same time), check the value of the PATH environment variable with echo $PATH. Then, try to make sure one of the directories in it is the one that holds the java executable. You can find which one is that with a command like grep '/bin/java$' /var/log/packages/j*

Edit: in my system:

Code:
$ ls -l /var/log/packages/j*
-rw-r--r-- 1 root root   1708 2009-04-08 14:25 /var/log/packages/jasper-1.900.1-i486-1
-rw-r--r-- 1 root root 285824 2009-04-08 22:13 /var/log/packages/jdk-6u13-i586-1
-rw-r--r-- 1 root root   1293 2009-04-08 22:13 /var/log/packages/jfsutils-1.1.13-i486-1
You can see I have jdk.

Code:
$ grep '/bin/java$' /var/log/packages/j*
/var/log/packages/jdk-6u13-i586-1:usr/lib/java/jre/bin/java
/var/log/packages/jdk-6u13-i586-1:usr/lib/java/bin/java
You can see "java" is in /usr/lib/java/jre/bin and /usr/lib/java/bin. If I check the PATH, I see:

Code:
$ echo $PATH
/home/rg3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/lib/java/bin:/usr/lib/java/jre/bin:/opt/kde3/lib/qt3/bin:/opt/kde3/bin:/usr/lib/qt/bin:/usr/share/texmf/bin
And "/usr/lib/java/bin" is right there, in the 7th position.

Last edited by rg3; 06-06-2009 at 03:18 AM.
 
Old 06-06-2009, 03:23 AM   #3
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Thanks for that.
Looks like its in usr/lib/java/bin/java

First I get
$ echo $PATH
/usr/local/bin:/bin:/usr/bin
then
$ grep '/bin/java$' /var/log/packages/j*
/var/log/packages/jre-6u11-i586-1:usr/lib/java/bin/java
so it looks like I have it in
usr/lib/java/bin/java
next prob - why shouldnt it work?
 
Old 06-06-2009, 03:37 AM   #4
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
/usr/lib/java/bin is not in the contents of PATH. Maybe it has to do with the way you start your terminal. Try to start it as a "login terminal" if possible. For example, check the following: run xterm -ls and a new terminal will pop up. In that new terminal, try to see if java -version works. If it works, that's the problem.
 
Old 06-06-2009, 04:38 AM   #5
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Yes you are quite right about that. Java responds from a command prompt as long as I open the terminal with xterm -ls. Thats a new one!

The last install I did had none of these complications (/learning curves!).
So how can I fix the PATH issue?
 
Old 06-06-2009, 04:55 AM   #6
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 34
Read up on bashrc, bash_profile and environment variables.
 
Old 06-06-2009, 05:06 AM   #7
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
Actually, I think it's not worth messing up with bashrc or bash_profile or anything as long as you can make sure your terminal starts a login shell. Most terminal programs (Konsole, for example) have a way to do that. You just need to find how. If you can't find the option, tell us the terminal you're using and someone will probably be able to tell you where the option is.
 
Old 06-06-2009, 10:02 AM   #8
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,585

Rep: Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165
Quote:
So how can I fix the PATH issue?
When you open a bash shell as a login shell, the /etc/profile script is executed. This script then looks for executable scripts in /etc/profile.d.
There are scripts (jre.sh, jre.csh, jdk.sh and jdk.csh) in /etc/profile.d that set the PATH. Check whether these scripts are executable.
If you open a bash interactive shell that is not a login shell, then the ~/.bashrc script is executed. If you want to add the java paths to your $PATH, then add lines to ~/.bashrc.
Code:
. /etc/profile.d/jre.sh
. /etc/profile.d/jdk.sh

Last edited by allend; 06-06-2009 at 10:36 AM.
 
Old 06-07-2009, 04:14 AM   #9
autophil
Member
 
Registered: Jun 2006
Location: Macclesfield Canal, East Cheshire
Distribution: Salix-14.1
Posts: 129

Original Poster
Blog Entries: 1

Rep: Reputation: 15
I dont seem to have a ~/.bashrc I did a 'locate' for a bashrc and a bash.rc
Nothing there! Maybe this is a problem.

There are 31 files altogether in /etc/profile.d
They are all owned by root and executable by owner group and others.(except scim)
I have the 2x Jre entries (jre.sh and jre.csh) but not the *.jdk

I think Im correct that most applications you install with some command line stuff but thereafter one can expect to start the application using a menu item.

I am unsure about whether a bash (interactive) is a login shell or not a login shell. I will have to do some serious reading on that.
 
Old 06-07-2009, 04:24 AM   #10
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 5,585

Rep: Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165Reputation: 2165
Quote:
I dont seem to have a ~/.bashrc
There is no ~/.bashrc by default. The file needs to be created.
Quote:
I have the 2x Jre entries (jre.sh and jre.csh) but not the *.jdk
This suggests that you have not installed the java development kit package.
Quote:
I am unsure about whether a bash (interactive) is a login shell or not a login shell
As you had the java starting when you started a login shell, then I suggest that you were originally starting not using a login shell.
 
Old 06-07-2009, 04:42 AM   #11
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
Usually you don't need to have a ~/.bashrc file unless you want to change a default shell setting for your user account or some other particular settings. Having the PATH environment variable properly set is not really part of that. Maybe this provides a good starting point:

http://slackwiki.org/Login_Shell
 
Old 06-07-2009, 04:58 AM   #12
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 34
Quote:
Originally Posted by rg3 View Post
Having the PATH environment variable properly set is not really part of that.
A part of what is it then?
 
Old 06-07-2009, 05:14 AM   #13
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
Part of launching the shell properly, of course. When you log in via a virtual terminal everything is set up properly. /etc/profile is sourced, and in turn this sources the contents of /etc/profile.d and you get the expected environment. It turns out when you launch a terminal emulator in X, the command line environment you get is not the same because the shell is not launched the same way, and it can be solved by launching the terminal emulator or shell properly, without "patching" stuff via ~/.bashrc or ~/.bash_profile.

I use those to add some personal directories to the PATH, or to establish some environment variables for my user account, but not for sourcing system files that are already sourced when you start the shell properly. It will work but, to give you an analogy, it's like hitting a nail with a wrench. I prefer to use a hammer and, when someone asks, that's the advice I like to give.
 
Old 06-07-2009, 05:26 AM   #14
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 34
A fine point. A side note: X virtual terminals represent a class of tools which need this sort of attention. GNU Screen also seems to need to be instructed in this sense. Having a bashrc + bash_profile [eventually one being a symlink to the other or somesuch] is a centralised solution for the above utilities.

Last edited by noctilucent; 06-07-2009 at 05:36 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LFS6.3 livecd "ls : command not found" error after "su - lfs" rotu Linux From Scratch 2 06-19-2008 03:59 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 01:21 AM
"No Java virtual machine could be found from your PATH" - ignores bashrc shaider Linux - Software 7 10-09-2004 12:38 AM
java command - "bash: java: command not found" ??? RedHat123 Programming 2 07-16-2002 11:09 PM

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

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