LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2006, 09:00 PM   #1
tkinsella
Member
 
Registered: Dec 2005
Distribution: CentOS 6.5
Posts: 45

Rep: Reputation: 0
Java Won't Work (Not like the previous post)


I have downloaded the newest J2SDK from Suns website.
I CHMOD it (a+x) and install it.
It seems to install with no errors.
Anytime I try to type a command (java, javac etc...) it comes back:

linux:/home/tkinsella/j2re1.4.2_10 # cd bin
linux:/home/tkinsella/j2re1.4.2_10/bin # java
bash: java: command not found
linux:/home/tkinsella/j2re1.4.2_10/bin # javac
bash: javac: command not found
linux:/home/tkinsella/j2re1.4.2_10/bin #
linux:/home/tkinsella/j2re1.4.2_10/bin #

Anythoughts? Thanks!
 
Old 02-11-2006, 09:32 PM   #2
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
Your java directory is not in $PATH, use ./java and ./javac instead or add the directory to yout $PATH:

PATH=$PATH:/home/tkinsella/j2re1.4.2_10/bin

this in your ~/.bashrc will make it permanent. Do you have a particular reason to have it installed under your home directory? /usr/lib or such would seem like a better place to me.
 
Old 02-11-2006, 09:43 PM   #3
tkinsella
Member
 
Registered: Dec 2005
Distribution: CentOS 6.5
Posts: 45

Original Poster
Rep: Reputation: 0
I tried using those commands and adding it to my $PATH and re-installing it in my /usr/lib and I still get the same error messsage that it cannot be found.
 
Old 02-11-2006, 10:02 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by tkinsella
I tried using those commands and adding it to my $PATH and re-installing it in my /usr/lib and I still get the same error messsage that it cannot be found.
Because you've done a mistake, but there is no way to figure it out if you do not write precisely what you did.

Show us:
your path: echo $PATH
the java command location: ls -l /somewhere/bin/java
the command you enter: java
the error message you got: ?
 
Old 02-11-2006, 10:31 PM   #5
tkinsella
Member
 
Registered: Dec 2005
Distribution: CentOS 6.5
Posts: 45

Original Poster
Rep: Reputation: 0
tkinsella@linux:~> echo $PATH
/home/tkinsella/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/home/tkinsella/j2re1.4.2_10/bin
tkinsella@linux:~>

tkinsella@linux:~/jdk1.5.0_06/bin> ls -l
total 3016
-rwxr-xr-x 1 root root 72760 2005-11-10 14:19 appletviewer
-rwxr-xr-x 1 root root 72752 2005-11-10 13:51 apt
-rwxr-xr-x 1 root root 4153 2005-11-10 14:47 ControlPanel
-rwxr-xr-x 1 root root 72752 2005-11-10 14:31 extcheck
-rwxr-xr-x 1 root root 1080 2005-11-10 14:47 HtmlConverter
-rwxr-xr-x 1 root root 72752 2005-11-10 13:58 idlj
-rwxr-xr-x 1 root root 72752 2005-11-10 14:01 jar
-rwxr-xr-x 1 root root 72752 2005-11-10 14:00 jarsigner
-rwxr-xr-x 1 root root 64812 2005-11-10 13:48 java
-rwxr-xr-x 1 root root 72752 2005-11-10 13:49 javac
-rwxr-xr-x 1 root root 72752 2005-11-10 13:50 javadoc
-rwxr-xr-x 1 root root 72752 2005-11-10 13:51 javah
-rwxr-xr-x 1 root root 72752 2005-11-10 14:22 javap
-r-xr-xr-x 1 root root 1789 2005-11-10 14:20 java-rmi.cgi
-rwxr-xr-x 1 root root 175978 2005-11-10 14:47 javaws
-rwxr-xr-x 1 root root 72752 2005-11-10 14:24 jconsole
-rwxr-xr-x 1 root root 72752 2005-11-10 14:33 jdb
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 jinfo
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 jmap
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 jps
-rwxr-xr-x 1 root root 72752 2005-11-10 14:24 jsadebugd
-rwxr-xr-x 1 root root 72752 2005-11-10 14:24 jstack
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 jstat
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 jstatd
-rwxr-xr-x 1 root root 72752 2005-11-10 14:00 keytool
-rwxr-xr-x 1 root root 72752 2005-11-10 14:00 kinit
-rwxr-xr-x 1 root root 72752 2005-11-10 14:01 klist
-rwxr-xr-x 1 root root 72752 2005-11-10 14:01 ktab
-rwxr-xr-x 1 root root 72752 2005-11-10 14:22 native2ascii
-rwxr-xr-x 1 root root 72752 2005-11-10 14:26 orbd
-rwxr-xr-x 1 root root 72752 2005-11-10 14:27 pack200
-rwxr-xr-x 1 root root 72760 2005-11-10 14:00 policytool
-rwxr-xr-x 1 root root 72752 2005-11-10 14:20 rmic
-rwxr-xr-x 1 root root 72752 2005-11-10 14:21 rmid
-rwxr-xr-x 1 root root 72752 2005-11-10 14:20 rmiregistry
-rwxr-xr-x 1 root root 72752 2005-11-10 14:23 serialver
-rwxr-xr-x 1 root root 72752 2005-11-10 14:26 servertool
-rwxr-xr-x 1 root root 72752 2005-11-10 14:26 tnameserv
-rwxr-xr-x 1 root root 394235 2005-11-10 14:26 unpack200

tkinsella@linux:~/jdk1.5.0_06/bin> javac
bash: javac: command not found
 
Old 02-11-2006, 10:47 PM   #6
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
Next time, rather than installing a big self-contained package into /usr/lib, consider
putting it into /opt (you'll have to create that directory if it's not already there).
You don't want to pollute your system directories (like /usr/lib) with big third-party
packages like that.

If you don't have root access, and if you've got some room on the /home partition, many
folks create an ~/opt directory there (right in their home directory).

In this opt dir, you end up with something like:

opt/java

opt/mysql

opt/other_big_selfcontained_package

And if you prefer installing other sundry software in there as well (say, you don't have
room on /usr/local, or don't have write access), just ./configure --prefix=/path/to/opt/local
to get a directory structure like:

opt/local/bin

opt/local/lib

opt/local/man

opt/local/src

opt/local/include

opt/local/doc

This way, the opt dir stays pretty clean and organized.

Last edited by johnMG; 02-11-2006 at 10:49 PM.
 
Old 02-11-2006, 10:55 PM   #7
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
BTW, I think you only want to add exported environment variable changes to your
~/.bash_profile, not your ~/.bashrc. The .bash_profile gets sourced once when you
log in. The .bashrc gets sourced every time you go into a subshell.

If you put things like "export PATH=/path/to/some/bin:$PATH" into your .bashrc,
then that PATH variable gets fiddled with everytime you enter a subshell. Not
a big deal, of course.

The .bashrc is more for adding aliases, and setting variables that are
constantly changing, like PS1.
 
Old 02-12-2006, 06:46 AM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by tkinsella
tkinsella@linux:~> echo $PATH
/home/tkinsella/bin:...:/home/tkinsella/j2re1.4.2_10/bin
tkinsella@linux:~>

tkinsella@linux:~/jdk1.5.0_06/bin> ls -l
total 3016
-rwxr-xr-x 1 root root 72760 2005-11-10 14:19 appletviewer
...
tkinsella@linux:~/jdk1.5.0_06/bin> javac
bash: javac: command not found
How do you want the shell to find javac if you give it a wrong PATH ?
 
Old 02-12-2006, 07:32 AM   #9
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
Yes, of course you must add the path to the directory that actually matches the version you have installed.
 
Old 02-12-2006, 02:54 PM   #10
tkinsella
Member
 
Registered: Dec 2005
Distribution: CentOS 6.5
Posts: 45

Original Poster
Rep: Reputation: 0
Ok, I changed the path and the Java command is the only one that works. Javac still will not.
I tried to install to ./opt and I get this error:
bash: ./j2sdk-1_4_2_10-linux-i586.rpm: cannot execute binary file.
I am running as root.
 
Old 02-12-2006, 03:34 PM   #11
jomen
Senior Member
 
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 55
Quote:
bash: ./j2sdk-1_4_2_10-linux-i586.rpm
now you are using an rpm package - some posts above this was:
1. not clear
2. another version (jdk1.5.0_06)

make sure you get rid of all the files from previous attempts to install it - and clean out your $PATH
you can adjust it again if the version you want to install now is installed
If it is an rpm and you are not on Debian Knoppix or Ubuntu...(deb) this should be installed via package-manager instead of doing it manually - it's much easier this way...
What distribution are you running?
BTW: I remember that the binary distributions always had instructions with them on how to set them up and add the binary to your PATH
 
Old 02-12-2006, 06:05 PM   #12
tkinsella
Member
 
Registered: Dec 2005
Distribution: CentOS 6.5
Posts: 45

Original Poster
Rep: Reputation: 0
Fixed

OK. I was using SUSE 10 and just switched over to RedHat 9 (Shrike) and every problem (Except my wireless card ) works!
 
Old 02-12-2006, 10:41 PM   #13
Fredstar
Member
 
Registered: Jul 2004
Location: Rochester, NY
Distribution: Fedora9::FreeBSD7.1
Posts: 296

Rep: Reputation: 30
Quote:
Originally Posted by tkinsella
OK. I was using SUSE 10 and just switched over to RedHat 9 (Shrike) and every problem (Except my wireless card ) works!

type the following in.

PATH=$PATH:/usr/java/jdk1.5.0_06/bin

and your problem is solved.

However, this is assuming your using jdk1.5.0_06. To make sure do the following

cd /usr/java/

ls -l

jdk.1.???? (this is the directory that will be the version)

if the directory as the same as my example then your fine. If not make the changes to the directory we put into the path.

later

Last edited by Fredstar; 02-12-2006 at 11:06 PM.
 
Old 02-13-2006, 01:03 AM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by tkinsella
Ok, I changed the path and the Java command is the only one that works. Javac still will not.
This is is your PATH is containing a jre and not a jdk, but you failed again to provide clues about what is installed, what is set, what you run and what you got ...

A JRE is only containing the runtime (java), while a JDK is containing the development tools in addition (javac).
 
Old 02-13-2006, 01:15 AM   #15
excel28
Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 72

Rep: Reputation: 15
Sorry... somebody above said what I said...

Last edited by excel28; 02-13-2006 at 01:16 AM.
 
  


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
FC4 gcc 4.0.2 does not work with TotalView, need previous version... salobaas Fedora 3 01-09-2006 05:28 AM
Transparency in Aterm won't work, fbsetbg won't set previous background rob0t Slackware 2 08-13-2005 06:37 PM
Hi Jeremy how do i check my previous post !! hitesh_linux LQ Suggestions & Feedback 8 12-18-2004 09:29 AM
Tomcat Startup (? is appendage to previous post) ChangeOfPace Linux - Software 7 05-01-2003 06:20 PM
Traversing from previous post c0rk3y *BSD 1 07-26-2002 09:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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