ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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 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 #
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.
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.
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
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: ?
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.
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.
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.
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
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.