HOW TO: Install Sun JRE Java on Linux Mint (script included)

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
grizzler

Re: HOW TO: Install Sun (Oracle) Java on Linux Mint

Post by grizzler »

c-m wrote:Doesn't java come installed as standard on mint 11?

I've got a package called Java(TM) Plug-in, Java SE 6 installed via the package manager.

It doesn't seem to work though with either Firefox or Chromium
If that's Java 6 update 26, it has probably been disabled automatically. Oracle withdrew the licence for updates by others and as 6u26 was known to be full of security holes, a final 'update' was delivered through the repositories, effectively switching it off.

http://www.omgubuntu.co.uk/2011/12/java ... -machines/
c-m

Re: HOW TO: Install Sun (Oracle) Java on Linux Mint

Post by c-m »

Followed the guide. It's easy enough, but really in this day and age, we shouldn't have to be doing this kind of thing.

It's a pain when it needs doing for two different browsers across 3 machines.

Takes me back to doing a stage 1 install of gentoo 7 years ago.
sagirfahmid3

Re: HOW TO: Install Sun (Oracle) Java on Linux Mint

Post by sagirfahmid3 »

NEW(er) UPDATE:
Well I've finished making the script for Java 7 installation. It should work for all Java 7 updates (unless Oracle happens to change their naming format for the archives).
Take time and READ THIS POST, or you might end up having trouble.

==================Average home pc users, read below==========================
Made a script to automate installation of Java. It is uploaded onto MediaFire. All you need to do is:
1. Download the latest Java (for Linux of course) from here: http://java.com/en/download/linux_manual.jsp?locale=en
2. Make sure you put the downloaded tar.gz archive in your home folder
3. EXTRACT the tar.gz archive and make SURE it's in the home folder (right click on the archive > "Extract here")
4. Download ONE of these scripts below (according to 32 or 64 bit). You can check your OS architecture by menu> terminal > "arch"
If it says i686, you would want the 32-bit script. If it says x86_64, you would want the 64-bit script

32-bit users, use this script: [work in progress]
64-bit users, use this script: [work in progress]

5. Now that you have the required items in your home folder, go ahead and open up a terminal
6. Type in "sh java32.sh" if you're on a 32-bit OS; type in "sh java64.sh" if you're on a 64-bit OS. Hit enter and you're set.

NOTE: For Java updates 1-9, please use 01,02,03...09 when prompted. (Again stated inside the script and when you run it).
NOTE2: You can ALWAYS check what stuff is contained within a shell script. You just open it up with a text editor like Leafpad or Gedit for example.
NOTE3: You may get a few minor errors such as: "mkdir: cannot create directory `java': File exists" "mkdir: cannot create directory `32' ('64'): File exists"
Or if the icedtea plugin isn't installed, you will get a "icedtea not installed so not removed" output. Ignore these (I have to add file checking to my script).
If you reach the line that says "If the output below matches the version that you installed, all is well", and you notice that the Java has been upgraded, that is all that matters.

===================================================
===========REMOVAL OF PREVIOUS VERSIONS============
To remove previous versions of Java (thereby saving ~100MB disk space for each version removed), you can simply remove that version by opening your file manager as root and going into /opt/java/{32,64}/ and removing the previous versions. So what you do is, open a run dialog by pressing Alt+F2, then type in "gksu thunar/pcmanfm/nautilus" <--choose your default file manager. Then follow what I said above. So lets say you have Java 7 update 5 (latest at the time I am writing this) and you also have Java 7 update 4 (older), you can delete that folder that says Java7u4.

==========================================================================
====================Geeks (or geeks in training), read below====================
If you want to, you can improve this script, but I would like it if you would paste the improvements on this page so that I can try it out before adding it to my current one.
And of course, credit will be given :roll:
Further improvement: at the moment, I am stuck at extracting from the shell script. What I would like is to extract using a wildcard (ex: tar xzvf jre-7u*.tar.gz) but this doesn't work when I try it INSIDE the script. If I try it in the terminal however, it works. I would like if someone would give a solution and post up an update to the script :D )
==========================================================================

THE STUFF BELOW IS WHAT IS CONTAINED INSIDE THE 32-BIT SCRIPT. You can check it yourself by right clicking > open with > gedit or leafpad or abiword , etc

Code: Select all

work in progress. should be done by a week.
THE STUFF BELOW IS WHAT IS CONTAINED INSIDE THE 64-BIT SCRIPT. You can check it yourself by right clicking > open with > gedit or leafpad or abiword , etc

Code: Select all

work in progress. should be done by a week.
Last edited by sagirfahmid3 on Thu Aug 30, 2012 8:59 am, edited 8 times in total.
HaMi

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by HaMi »

Oracle Java SE 7 Update 04 is installed in my Mint 9 in this way, and works fine in Chromium and Firefox.
Reason I dont know, but in first installation there was error, so I did it twice, and reboot PC.
It works in Ubuntu 10.04 too.
Terminal: (dont hurry)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Yea, but see, that's a PPA. The thing with that is anyone can create one, even someone with malicious intents, so instead of my script actually downloading things from unknown places, I specifically tell the people to download the official Java from Oracle's main site (www.java.com). Also, that script is so that people can clearly see what is going on under the hood. It offers some a peace of mind, and to me, it offers convenience (try installing Java and adding PPAs on multiple computers, takes too long).
cowsquad

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by cowsquad »

Great tutorial

Sent from my Galaxy Nexus using Tapatalk 2
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Thank you. I'll try and get working on the latest script this week.
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Well, it's up. The updated script. It should work for all Java version 7 with all updates. Comments or suggestions appreciated.
PJC

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by PJC »

Hello

I'm sorry but it did not work for me and I've tried for an hour to install Java 7 so I can run one program.

Very tired and fustrated.

Will try again tomorrow.

There must be a better way to do this

Regards

Paul
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Well, it should work. I tried it on my craptop (a crappy laptop) and it works (so far I've tried it on 2 of my own machines).
Are you sure you have the tar.gz archive in your home folder? Did you save it with a different name maybe?
Did you paste the contents of ONE of the codeboxes inside a file, then rename the extension to java.sh?

"What you want to do is open up Gedit or Leafpad, paste the contents of ONE of the boxes below ACCORDING TO YOUR OS ARCHITECTURE, THEN save the file as java.sh (you can name it something else if you want, but the IMPORTANT part is you NEED a .sh at the end of it). Now, to actually INSTALL, open up a terminal and type in "sh java.sh" (again, assuming you actually saved it in your HOME FOLDER"
PJC

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by PJC »

Hello

I think I did all this and here is the error I am getting (I think that this bit is important. It is Moneydance I am trying to get to work.

Start

Preparing JRE ...
/var/lib/dpkg/info/moneydance.postinst: 22: /var/lib/dpkg/info/moneydance.postinst: bin/unpack200: not found
Error unpacking jar files. Aborting.
dpkg: error processing moneydance (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
moneydance
E: Sub-process /usr/bin/dpkg returned an error code (1)
rm: cannot remove `/root/.mozilla/plugins/libnpjp2.so': No such file or directory
ln: target `/root/.mozilla/plugins/' is not a directory: No such file or directory
If the output below matches the version that you installed, all is well
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)
You can also check manually by opening Firefox and going to about:plugins
Yet another way to check your Java version is by going to www.java.com. Click 'Do I have Java?'

End

I admit I am not a geek but nothing should be this hard. I'm sorry but this just seems to me to very difficult to get one pice of software running.

Regards

Paul
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Holy crap...It doesn't paste it like it copies it. That was why it wasn't working. Hold on let me just upload the script file instead to Mediafire. Makes it much easier.
Sorry for the inconvenience, I didn't notice that Gedit pastes the text weirdly.

Look back up at post # 3. I put a MediaFire link to the shell script. You can ALWAYS look inside a shell script using a text editor to see what's going on. Just a good idea.

Edit: Lol, that gave me something to do today! I was bored out of my mind...
Anyways, it's fixed now. I even removed Java so I could reinstall it again using the remade script.
truexfan81

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by truexfan81 »

thanks man, worked great on mint 13 mate 64
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

No problem dude. By the way, this script will work will Debian based distros (Debian, Ubuntu, Mint, etc).
I haven't tried it on any RPM based distros so don't blame me if it doesn't work on those.
PJC

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by PJC »

Hello

Still does not work for me when I use your script.

I have tried as root as as me and get this outcome

paul@paul-mint12 ~ $ sh java64.sh
Hi there. I hope you like this script. It is here to make life easier for those
who are having difficulty installing Java manually. As a noob myself at shell
scripting, I have kept this simple and straight forward to use.
Should you have any questions, or if the script fails to work,
please let me (sagirfahmid3) know. Also, feel free to improve upon this script
and don't forget to share it here!

Installation will now start. Do you want to proceed? (Y/N)
<Entering other keys will abort installation>y
[sudo] password for paul:
mkdir: cannot create directory `java': File exists
mkdir: cannot create directory `64': File exists
Which UPDATE of Java version 7 are you installing? Type version # & press ENTER
This should be written on the tar.gz archive as jre7-u{#}-linux-x64.tar.gz
IMPORTANT NOTE: For Java updates between 4 to 9, please use 04,05...09 when prompted!
04
mv: cannot move `/home/paul/jre1.7.0_04' to `/opt/java/64/jre1.7.0_04': Directory not empty
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package icedtea6-plugin is not installed, so not removed
The following packages were automatically installed and are no longer required:
language-pack-kde-zh-hans-base firefox-locale-zh-hans language-pack-kde-en
kde-l10n-engb language-pack-zh-hans-base kde-l10n-zhcn language-pack-zh-hans
language-pack-kde-zh-hans language-pack-kde-en-base
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
rm: cannot remove `/home/paul/.mozilla/plugins/libnpjp2.so': No such file or directory
If the output below matches the version that you installed, all is well
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode)

Sorry but it just does not work

I'm off to works so will try this afternoon

Paul
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

It DOES work :x :

Code: Select all

If the output below matches the version that you installed, all is well
java version "1.7.0_04"
^^Did you even open up Firefox to check the version?
Type this in the terminal: "java -version"
It's not giving any REAL error messages. I'm sure you already have the latest Java installed, but you're just not getting what I AM SAYING.

Code: Select all

mv: cannot move `/home/paul/jre1.7.0_04' to `/opt/java/64/jre1.7.0_04': Directory not empty
<--It's saying that you ALREADY HAVE the latest Java in the /opt/Java folder so it's not going to overwrite it.

Code: Select all

rm: cannot remove `/home/paul/.mozilla/plugins/libnpjp2.so': No such file or directory
<--This part comes BEFORE a symlink is made. If it doesn't find a Java plugin, this output is made. If it DOES find a version of the plugin, it gets replaced with the latest one.

So, please open up Firefox or your favorite browser and go to http://www.java.com and click "Do I have Java."
Verify the version. If it says you have version 7 update 4, well then there you go, its fine.
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

Ya, see? I told ya it worked :P
deleted

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by deleted »

Not sure why you need this, instead of the openJDK in the repos?
-H
sagirfahmid3

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by sagirfahmid3 »

If anyone happens to have a question like hinto, well here's the answer:
http://stackoverflow.com/questions/1977 ... vice-versa
deleted

Re: HOW TO: Install Sun Java on Linux Mint (script included!

Post by deleted »

I guess my point it that I develop Java applications professionally.
The full stack, JNI, RMI, JBoss, Web Services etc.
I see absolutely no discernible difference between the 2 (starting with jdk 1.6).
-Hinto
Post Reply

Return to “Tutorials”