I’m trying to install Java SE Development Kit 8u71 from here.
I also read this, this, this, and this (posts about installing Java).
So, this is my status:
I have the ‘jdk-8u71-linux-x64.rpm’, I want to install it with:
marc@TheD:~/Downloads> sudo rpm -ivh --nodeps jdk-8u71-linux-x64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8.0_71-2000:1.8.0_71-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
update-alternatives: using /usr/java/jdk1.8.0_71/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: error: alternative ControlPanel can't be slave of javac: it is a slave of java
warning: %post(jdk1.8.0_71-2000:1.8.0_71-fcs.x86_64) scriptlet failed, exit status 2
That doesn’t work because I still have the openJDK installed.
I already removed most of it but I am stuck with ‘java-1_8_0-openjdk’ and ‘java-1_8_0-openjdk’.
I am trying to remove these 2 packages as well (in Yast) but Yast keeps installing the 1_7_0 version simultaneously.
I don’t know how to stop that.
For why I don’t use openJDK: I try to get rJava (R) running and it has a problem with the compiler. Turns out openJDK sometimes has issues, they say oracle compiler is better.
I think you have a few things mixed up, installing Oracle’s jre does not remove openjdk, actually there was a bug in oracle’s rpm that didn’t state that Oracle provided java so removing openjdk will remove any application that depends on java, the thing to do is install Oracle’s jre and then use tsu2’s link to set it as the default java vm, do not try to remove openjdk as that will cause a lot of other issues just use update-alternatives according to this thread https://forums.opensuse.org/showthread.php/512626-Java-8-jdk-and-update-alternatives-on-Leap
edit
maybe
sudo rpm -ivh --nodeps jdk-8u71-linux-x64.rpm
is not the best way to install an rpm try using zypper as Oracle’s jre might need other packages, do
I get what you mean. I need to create all these links after installing oracle java so that I can actually choose it as default.
However, I don’t even get to install it.
the zypper command gives the exact same error:
marc@TheD:~/Downloads> sudo zypper in jdk-8u71-linux-x64.rpm
Daten des Repositories laden ...
Installierte Pakete lesen ...
Paketabhängigkeiten auflösen ...
Das folgende NEUE Paket wird installiert:
jdk1.8.0_71
1 neues Paket zu installieren.
Overall download size: 152,7 MiB. Already cached: 0 B. Nach der Operation werden zusätzlich 255,4 MiB
belegt.
Fortfahren? [j/n/? zeigt alle Optionen] (j): j
Paket jdk1.8.0_71-2000:1.8.0_71-fcs.x86_64 wird abgerufen (1/1), 152,7 MiB (255,4 MiB entpackt)
Test auf Dateikonflikte: ......................................................................[fertig]
(1/1) Installation von: jdk1.8.0_71-2000:1.8.0_71-fcs .........................................[fertig]
Zusätzliche RPM-Ausgabe:
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
update-alternatives: using /usr/java/jdk1.8.0_71/jre/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: error: alternative ControlPanel can't be slave of javac: it is a slave of java
warning: %post(jdk1.8.0_71-2000:1.8.0_71-fcs.x86_64) scriptlet failed, exit status 2
what error?
according to google translate you installed jre but update-alternatives couldn’t set it as the default runtime that’s where the how-to from the above link comes handy, you’d need to make a new script and execute it as root reread the howto
just a quck note the howto is for jre 8u66 you have 8u71 so you;d need to change the path /usr/java/jre1.8.0_66 to /usr/java/jre.8.0_71 or similar see where the jre has actually ended up
The reference I provided says (yes, it’s hidden in there) to install Oracle SE 8 JDK (not JRE). The JDK includes the JRE but also provides the additional Developer applets.
It doesn’t say whether it should be installed using the TAR or RPM, but for now my educated guess is the RPM which would install files in a known location and would be essential for the scripts setting update-alternatives.
Be aware that historically, installing Oracle Java packages using the TAR file has stomped all over previous Java.
update-alternatives: using /usr/java/jdk1.8.0_71/jre/bin/java to provide /usr/bin/java (java) in auto mode update-alternatives: error: alternative ControlPanel can't be slave of javac: it is a slave of java warning: %post(jdk1.8.0_71-2000:1.8.0_71-fcs.x86_64) scriptlet failed, exit status 2
I would interpret this as: while unpacking there is already an issue which stops the installation process.
Now, just to be sure I ran the 2 mentioned scripts. I just change the pattern “0_66” to “0_71” in the scripts (the jdk version I downloaded).
The first one gave me:
marc@TheD:~/Downloads> sudo ./setting-up-sun-jdk_1.sh
update-alternatives: warning: forcing reinstallation of alternative /usr/java/jdk1.8.0_71/jre/bin/java because link group java is broken
update-alternatives: warning: skip creation of /usr/share/man/man1/java.1 because associated file /usr/java/jdk1.8.0_71/man/man1/java.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/keytool.1 because associated file /usr/java/jdk1.8.0_71/man/man1/keytool.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/orbd.1 because associated file /usr/java/jdk1.8.0_71/man/man1/orbd.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/policytool.1 because associated file /usr/java/jdk1.8.0_71/man/man1/policytool.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/rmid.1 because associated file /usr/java/jdk1.8.0_71/man/man1/rmid.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/rmiregistry.1 because associated file /usr/java/jdk1.8.0_71/man/man1/rmiregistry.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/servertool.1 because associated file /usr/java/jdk1.8.0_71/man/man1/servertool.1 (of link group java) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/tnameserv.1 because associated file /usr/java/jdk1.8.0_71/man/man1/tnameserv.1 (of link group java) doesn't exist
The second one gave me:
marc@TheD:~/Downloads> sudo ./setting-up-sun-jdk_2.sh
update-alternatives: error: alternative pack200 can't be slave of javac: it is a slave of java
Just to finish all mentioned steps, here is update-alternatives:
marc@TheD:~/Downloads> sudo update-alternatives --config java
root's password:
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/java/jdk1.8.0_71/jre/bin/java 18071 auto mode
1 /usr/java/jdk1.8.0_71/jre/bin/java 18071 manual mode
2 /usr/lib64/jdk_Oracle/bin/java 3 manual mode
3 /usr/lib64/jvm/jre-1.5.0-gcj/bin/java 1500 manual mode
4 /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java 1805 manual mode
Press enter to keep the current choice
[li], or type selection number: 2[/li]update-alternatives: using /usr/lib64/jdk_Oracle/bin/java to provide /usr/bin/java (java) in manual mode
I mean, I can choose jdk_Oracle now, so thanks very much.
But is the installation supposed to have all these warnings?
I guess something goes wrong right?
it’s good that you got it working, it’s an old issue with Oracle’s rpm, you’d think now they provide an rpm based Linux distro of their own they’d manage to make proper rpm files but you’d be wrong.
no (there sort of is) as the Oracle rpm does not state that it provides java so by removing openjdk zypper or yast will try to remove all applications that depend on java, you could go thru a long list of dependency errors and chose ignore on them all, but it’s safer just to keep openjdk.
what’s not working that’s a source java file you need to compile it to an intermediary class or jar file, what compiler did you use?
it looks like you don’t have a java compiler installed
openjdk does not come with a java compiler for that you need to install java-1_8_0-openjdk-devel
zypper in java-1_8_0-openjdk-devel
and oracle’s jdk is a separate download, maybe you haven’t configured oracle’s javac
update-alternatives javac
marc@TheD:~> sudo update-alternatives --config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /usr/lib64/jvm/java-1.5.0-gcj/bin/javac
Nothing to configure.
(why 1.5?!)
and then I installed java-1_8_0-openjdk-devel
But still the same: compiler not functional.
marc@TheD:~> sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_71
Java home path : /usr/java/jdk1.8.0_71/jre
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function `_start':
/home/abuild/rpmbuild/BUILD/glibc-2.19/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main'
collect2: error: ld returned 1 exit status
Java compiler : not functional
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/lib64/R/include -DNDEBUG -I/usr/java/jdk1.8.0_71/jre/../include -I/usr/java/jdk1.8.0_71/jre/../include/linux -I/usr/local/include -fpic -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib64/R/lib -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/java/jdk1.8.0_71/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR
JAVA_HOME : /usr/java/jdk1.8.0_71/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib64/R
Done.
So, I guess there was never a problem with rJava (my original issue) and openjdk.
It seems that my java(s) are generally somehow messed up.
If I install openjdk-1_7 -> remove openjdk-1_8 (also devel) , remove oracle java -> then install openjdk-1_8 (with devel and everything) again -> remove openjdk-1_7
would that be equal to a new installation?
Turns out, there was never a problem with the openJDK compiler, but with the gcj compiler.
I installed the new openJDK 1.8.0 version via YaST today, which basically fixed my problems with the compiler.
Before, update-alternatives only saw the 1.5.0-gcj compiler now I can choose from both:
marc@TheD:~> sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib64/jvm/java-1.8.0-openjdk/bin/javac 1805 auto mode
1 /usr/lib64/jvm/java-1.5.0-gcj/bin/javac 1500 manual mode
2 /usr/lib64/jvm/java-1.8.0-openjdk/bin/javac 1805 manual mode
HelloWorld example worked and R javareconf doesn’t complain anymore.