Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java installation issues on Ubuntu

Tags:

java

linux

ubuntu

Trying to install Java (JDK 6) on my new Ubuntu system and getting some bizarro errors. This is my first time ever using any flavor of Linux and so I'm sure it's a user issue (permissions or otherwise).

I downloaded the BIN file directly off Oracle's site (Java SE 6u23 for 64-bit Linux). This defaulted to downloading to /home/myUserName/Downloads.

From there I moved the file to /opt/java, which was a directory I created, because (as a Linux novice) that made sense to be the directory where Java should go.

I then ran the following 2 commands, per instruction I found online for running BINs:

chmod +x jdk-6u23-linux-x64.bin
sudo ./jdk-6u23-linux-x64.bin

Now, in my /opt/java directory I see both the BIN file and the jdk1.6.0_23 directory that seems to be intact upon inspection.

But, when I open a new terminal and run java -version, I get:

The program 'java' can be found in the following packages:
- gcj-4.4-jre-headless
- gcj-4.5-jre-headless
- openjdk-6-jre-headless
Try: sudo apt-get install

What is going on here?!?

(1) Was I wrong to try and make /opt/java my Java directory?
(2) Did I run the wrong commands?
(3) Is Java 1.6.0_23 even installed on my machine?
(4) What are all those gcj-xxx-headless targets?!?!

Thanks for any input!

like image 368
Zac Avatar asked Jan 02 '11 15:01

Zac


People also ask

Why is Java not installing correctly?

Active firewall or antivirus software may prevent Java from installing properly. Remember to turn your firewall or antivirus software back on when you have successfully completed the Java install.

Is Java compatible with Ubuntu?

Ubuntu offers the default-jre package, which is regularly updated to ship the latest version of the current OpenJDK JRE in Long Term Support (LTS). The default-jre is an excellent choice for most situations, thanks to the outstanding track of backwards compatibility of the Java Virtual Machine.


1 Answers

Was I wrong to try and make /opt/java my Java directory?

Not really. Many Java developers install multiple JDK installations and always use /opt/jdk1.6.0_23 or similar paths. The bin file you downloaded is not an installer, but merely an extractor. It does not install the java binaries into system folders like /bin.

I usually download the JDK and execute it from within my home folder and afterwards move it to /opt and performing an chown.

Did I run the wrong commands?

Not really. In case you wanted to install a separate JDK, you did it correctly. In case you wanted system integration, you would be better off to use the distribution-specific packages, such as the one installed via aptitude install sun-java6-jdk or alike.

The bin you downloaded is imho more flexible, since I can use it to install multiple verisons of Java on the same system. I know this is something you don't often do on Linux machines.

If you want to use the java binary on command line, you'd have to manually set up the PATH and JAVA_HOME environment variables. I think on Ubuntu that's /etc/environment or /etc/profile or something like that.

Is Java 1.6.0_23 even installed on my machine?

Not really. See above answers.

What are all those gcj-xxx-headless targets?!?

The GCJ is the Gnu Compiler for Java. Obviously, it includes a Java Development Kit and a Java Runtime Environment.

like image 152
mhaller Avatar answered Oct 08 '22 15:10

mhaller