Linux Lite Forums

Software - Support => Tutorials => Topic started by: Jerry on December 24, 2015, 11:20:55 PM

Title: How to Install Java on Linux Lite
Post by: Jerry on December 24, 2015, 11:20:55 PM
Install Java on Linux Lite - this tutorial will show you how to install Oracle's Java on Linux Lite. You must uninstall the openjdk java on Linux Lite first to have your system recognize and use Oracle's Java. Go into Synaptic package manager and remove packages labeled as 'openjdk' there will be only 2. An example of why people may want to use Oracle's Java over OpenJdk's Java is that they find Minecraft will only run under Oracle's or runs better under Oracle's Java.

NB: Best practice is to use only one type of Java on your system at a time. Yes, you can use symlinks, but this OS is for new folk to linux so we're keeping this very simple.

1. Download Java: 32bit or 64bit depending on your system - https://www.java.com/en/download/linux_manual.jsp (https://www.java.com/en/download/linux_manual.jsp)

(http://i.imgur.com/DHRxzVl.png)

2. Open a terminal where the download is and enter:

Code: [Select]
sudo su
Code: [Select]
mkdir /usr/lib/jvm/oracle_jdk8
Code: [Select]
tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
Code: [Select]
touch /etc/profile.d/oraclejdk.sh
Code: [Select]
leafpad /etc/profile.d/oraclejdk.sh
copy and paste the following into the file, then save and close it:

Code: [Select]
export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db

In the same terminal type, exit.

Now enter:

Code: [Select]
source /etc/profile.d/oraclejdk.sh
Do:

Code: [Select]
java -version
in a terminal to confirm you have Oracle's Java installed.

Code: [Select]
jerry@jerry-VirtualBox:~$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) Server VM (build 25.66-b17, mixed mode)
jerry@jerry-VirtualBox:~$
Title: Re: How to Install Java on Linux Lite
Post by: LinuxNoob on January 27, 2016, 09:14:05 PM
I would like to add this webpage that I found that could make it a bit easier to install the Java JRE

https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get

I appreciate it when installers exist to make my LL experience more FUNNER! :)

Code: [Select]
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer


It starts an installer. The page also has other versions

Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on February 29, 2016, 01:38:27 PM
how do I uninstall java
Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 24, 2016, 01:05:46 PM
How can I uninstall Java as I do not need it anymore?
Title: Re: How to Install Java on Linux Lite
Post by: avj on March 25, 2016, 01:07:22 PM
If you know which packages were installed, they can be removed from: Install/Remove Software. Make sure to only remove what you installed as some java packages may have been installed by default, and removing them may cause system problems.
Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 30, 2016, 12:05:46 PM
Not OpenJDK but Oracle's
Title: Re: How to Install Java on Linux Lite
Post by: Wirezfree on March 30, 2016, 12:57:34 PM
Does this help..??
Via the FAQ's on the download page: How do I uninstall Java for Linux ?
https://www.java.com/en/download/help/linux_uninstall.xml (https://www.java.com/en/download/help/linux_uninstall.xml)
Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 30, 2016, 05:06:53 PM
Well I used this guide and it seemed confusing.

Sent from my K00L using Tapatalk

Title: Re: How to Install Java on Linux Lite
Post by: Jerry on March 30, 2016, 05:08:42 PM
We need to know how you installed it in the first place.
Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 31, 2016, 01:21:51 AM
Go up to the first post exactly like it. Same commands and everything.

Sent from my K00L using Tapatalk
Title: Re: How to Install Java on Linux Lite
Post by: Jerry on March 31, 2016, 01:52:00 AM
Open a terminal, try:

Code: [Select]
sudo su
cd /usr/lib/jvm
rm -rf oracle_jdk8/
rm -rf /etc/profile.d/oraclejdk.sh

then:

Code: [Select]
java -version
should return something like:

Code: [Select]
test32@test32-VirtualBox:~$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-4.8-jre-headless
 * openjdk-7-jre-headless
 * gcj-4.6-jre-headless
 * openjdk-6-jre-headless
Try: sudo apt-get install <selected package>
test32@test32-VirtualBox:~$

If it doesn't, reboot and try java -version again.
Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 31, 2016, 01:59:36 AM
I still have openjdk so I assume it will be the same

Sent from my K00L using Tapatalk

Title: Re: How to Install Java on Linux Lite
Post by: stop0x0000000a on March 31, 2016, 02:19:39 AM
I still have openjdk so I assume it will be the same

Sent from my K00L using Tapatalk

Java is just a folder + a couple of environment variables.
No folder = no java anymore.

You can have more than one JDK installed, this case that profile JAVA_HOME selects the particular one to use.



Title: Re: How to Install Java on Linux Lite
Post by: liamjake05 on March 31, 2016, 04:18:35 AM
So what do you mean

Sent from my K00L using Tapatalk

Title: Re: How to Install Java on Linux Lite
Post by: stop0x0000000a on March 31, 2016, 06:37:26 AM
So what do you mean

if you have done the things above:

Code: [Select]
cd /usr/lib/jvm
rm -rf oracle_jdk8/

you've completed your mission successfully, no more Java ;)

I am a Java programmer actually, dozen of JVM installed and I simply delete their folders, if they are not needed anymore.
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 09:17:19 AM
Would like to install Oracle's Java for Pogo games. When I search in Synaptic I have 7 openjdk installed in my LL 2.8 and 9 installed in my LL 3.0 that I would like to install Oracle's Java in.
The tutorial said there would be only 2, not sure what to do.
Thanks, Wayne.
Oops, looks like the green squares are the installed ones, not the stars beside them. But my LL 2.8 has 2 squares and my LL 3.0 has 4?
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 10:51:15 AM
@waynebob...

Some of those are probably dependencies and/or documentation.. The description will inform their purpose...

Note the color of the box - not the start  ;)
Green is installed, you'll want to mark for removal

For openjdk - mark the JDK and the JDK source files (description) when marking for removal it should remove the dependencies as well..

Also look for ICEDTEA its another java program, remove in similar..

Once removed, double check if there are other "java"/"jdk" files installed you can select for removal...

Then follow Jerry's info to install - It works very well....
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 01:16:57 PM
Okay I did the first copy/paste for sudo su then the next to mkdir etc. and it says cannot create directory and no such file or directory? Not sure what I am doing wrong.
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 02:04:08 PM
Make sure you're coping the commands exactly - you can use the select to highlight then copy and using the terminal edit,to paste the commands in..

for sudo su it should of prompted for a password I assume you entered the  password and was accepted..

Again for mkdir ensure all "/" are in context...
/usr/lib is an actual directory usr/lib is not

FYI - If a command has a capital it must be entered with same capital...
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 02:57:38 PM
I open a terminal in the downloads box and copy/paste sudo su and get in root with red writing then copy/paste the next line to create the directory. Here's what I get, didn't know you could copy/paste the command box.

linuxlite@linuxlite-H170-D3HP:~/Downloads$ sudo su
[sudo] password for linuxlite:
root@linuxlite-H170-D3HP:/home/linuxlite/Downloads# mkdir /usr/lib/jvm/oracle_jdk8
mkdir: cannot create directory ‘/usr/lib/jvm/oracle_jdk8’: No such file or directory
root@linuxlite-H170-D3HP:/home/linuxlite/Downloads#
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 08:10:09 PM
See if you can cd to the jvm directory

Code: [Select]
cd /usr/lib/jvm
If not maybe this directory needs created prior??
Code: [Select]
mkdir /usr/lib/jvmthen
Code: [Select]
mkdir /usr/lib/jvm/oracle_jdk8
Might be worth a try... If not it maybe a permissions issue?
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 10:31:43 PM
The second and third instructions allowed me to finish Jerry's tutorial (except for the last one which is probably for Jerry's computer?)
Now I am going in circles trying to allow Java in my Firefox or Chromium browsers.
Starting to regret even starting this, all I find including on Java's website includes simlinks and I don't want to screw up this new install any more than I already might have.
Thanks for your help, Wayne.
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 10:41:58 PM
His last is an output...

What do you get when you run?
Code: [Select]
java -version
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 10:43:58 PM
linuxlite@linuxlite-H170-D3HP:~$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>
linuxlite@linuxlite-H170-D3HP:~$
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 28, 2016, 10:48:00 PM
I even did both browser Java stuff on their website and neither browser shows the plugins or will work at Pogo for the wife's game. Crap.

https://www.java.com/en/download/help/enable_browser_ubuntu.xml
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 10:55:31 PM
OK so java isn't installed yet..

So I assume you've downloaded java and its in your download folder if so...
You can open terminal from here...

This will unzip/install
Code: [Select]
tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
Allow to run then
Code: [Select]
touch /etc/profile.d/oraclejdk.shCreates the file oraclejdk.sh

The next command will open the newly created file in a text editor (leafpad - similar to notepad)
Code: [Select]
leafpad /etc/profile.d/oraclejdk.sh
Leafpad will be blank - copy the next few lines into the document and save..
Its "coded" to ease selecting, just select and copy then paste into leafpad)
Code: [Select]
export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db

Once you have the above pasted and saved (file-save) you can close.
then in the terminal window
Code: [Select]
source /etc/profile.d/oraclejdk.sh
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 11:07:56 PM
You're just about there - I've installed Oracle java this way several times :) I use it for work and once installed it works fine...
I don't use pogo - but have had to "support" it for some friends - Pogo uses a lot of flash.. I checked and was prompted to update my flash (adobe) - prompts for .tar.gz and apt... Don't use yum or rpm (other distro's)..

I'll look to see if I see anything in regards to flash here.. but I assume pretty straight forward :)
Flash is installed by default..
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 28, 2016, 11:21:58 PM
Once java is installed..
Code: [Select]
java -version should show an output similar to this

dad@TRCD-LLMini:$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode)

If you need the java control panel after its installed you can run the following in terminal..(it will open a GUI)
Code: [Select]
/usr/lib/jvm/oracle_jdk8/bin/jcontrol
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 29, 2016, 12:14:54 AM
This is what I show now.
linuxlite@linuxlite-H170-D3HP:~$ java -version
The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>
linuxlite@linuxlite-H170-D3HP:~$
I think this is a lost cause, the last instructions did not go perfectly.
Both Firefox and Chromium are complaining about Flash, Chrome is okay.
The Java for Perfect Pair Solitaire is still MIA. :-)
Tired and will look at this again in morning.
Thanks for your help, I am getting too old (67) for all this brain teasing.
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 29, 2016, 08:05:00 AM
Is there any errors when running the script?
Code: [Select]
tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
Something to confirm from the Java download page https://www.java.com/en/download/linux_manual.jsp

You downloaded the correct version for your OS?
- Java x64 for 64bit LL or Java for 32bit LL
Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 29, 2016, 08:56:36 AM
 Good Morning, haven't given up on me yet eh? ;-) Yes I downloaded the 64 bit  that Jerry recommended. Here is what I get when running your script.
linuxlite@linuxlite-H170-D3HP:~$ tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
tar (child): jre-*: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
linuxlite@linuxlite-H170-D3HP:~$

Well I sure am getting practice using the terminal. That is a good thing right.
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 29, 2016, 11:14:12 AM
Given up LOL; naw you're almost there - just little things, no show stoppers... :)
Just to confirm, your version of Linux lite is also 64bit?

So the error says there's no jre file.. It needs the correct location - you can cd to the full path or
Open Thunar (file manager) to the location of the downloaded JRE file. If its in your downloads folder open download.
Then right click (a blank area) and I believe its open terminal from here - you want terminal to be pointing to your downloads..

If you open terminal and its at "~" (aka your home folder - /home/user) You can cd to Downloads,
Code: [Select]
cd Downloads
The above is the same as the command below - assuming your username is linuxlite
Code: [Select]
cd /home/linuxlite/Downloads
You can confirm you are in the correct directory by typing
Code: [Select]
lsThis will list the items of the directory (folder) you're currently in (Downloads in this case) you should see the jre file listed - if not cd to the correct directory..

Then you can run the tar command..
Code: [Select]
tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
If you have already done the touch and leafpad commands those should be fine as is..
I would finish with the
Code: [Select]
source /etc/profile.d/oraclejdk.sh

Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 29, 2016, 11:36:02 AM
Crap, reading this do I have to unzip the downloaded file first. I am in the downloads folder but the file is still compressed.
Unzipped the file and it now shows. Tried the next step and got a very long message that it did not work. Should I put it here, it is very long?
Maybe my previous missteps have borked the install.
Redid Jerry's instructions and it worked now. I didn't even think to unzip the downloaded file, rookie mistake.
Now just have to get it working in Firefox and Chromium.
I see Chrome is going to stop using Flash in September so more fun ahead. :-)

Here is what I have now, looks like it worked.linuxlite@linuxlite-H170-D3HP:~$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
linuxlite@linuxlite-H170-D3HP:~$
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 31, 2016, 08:23:20 AM
Good to see you got it!!!! :)

The tar command will extract the compressed file..

Shortened explanation of the command tar -zxvf jre-* -C /usr/lib/jvm/oracle_jdk8 --strip-components=1
tar -zxvf extracts the compressed jre file (more so any file starting with jre-); into the directory../oracle_jdk8 ..


Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 31, 2016, 09:38:03 AM
Still don't have Java working in Chrome, Firefox or Chromium. Tried the Java website to enable FF and Chrome but didn't work.
Chrome no longer supports NPAPI (Java) and will no longer support Flash in September.
Chromium needs Flash update and Java is a no go.
Firefox needs Flash update (YUM or APT) and Java is a no go.
I was searching for a "best linux for Java and Flash" and downloaded Ubuntu Gamepack and PlayLinux thinking maybe they would be set up for online gaming. Still fooling around in Virtual Box, no luck yet.
Thanks for your help, Wayne.
P.S. I installed Teamviewer
Title: Re: How to Install Java on Linux Lite
Post by: firenice03 on August 31, 2016, 11:50:49 AM
I'm not in front of my LL box..
But for the Flash you want the APT not Yum.. If I recall if once APT file is downloaded it install easily; similarly to how Synaptic does..

For enabling in the browser, I believe in the Java Control panel (see the path I listed in a previous thread) under Security there is a check box to enable in the browser...


Title: Re: How to Install Java on Linux Lite
Post by: waynebob on August 31, 2016, 02:18:59 PM
On both my LL 2.8 and LL 3.0 my installed Flash is Ver. 11.2.202.632.
Go to Adobe, select APT for Ubuntu and download now, get "the address wasn't understood, Firefox doesn’t know how to open this address, because one of the following protocols (apt) isn’t associated with any program or is not allowed in this context.
 You might need to install other software to open this address.

And in the Java Control Panel the enable Java content in the browser is enabled.
The Java version appears to be a Server VM.
linuxlite@linuxlite-H170-D3HP:~$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
linuxlite@linuxlite-H170-D3HP:~$ /usr/lib/jvm/oracle_jdk8/bin/jcontrol
linuxlite@linuxlite-H170-D3HP:~$ /usr/lib/jvm/oracle_jdk8/bin/jcontrol
linuxlite@linuxlite-H170-D3HP:~$