Resolving class path for openjdk-9-jre downloaded version

Need help with C, C++, perl, python, etc?

Resolving class path for openjdk-9-jre downloaded version

Postby ashikuzzaman.ar » 2017-10-04 20:52

Hello there,
I'm a Java developer. I'm using Debian-9 Gnome. By default openjre-8 is installed on this system. I have downloaded openjdk-9 from [url]download.java.net/java/GA/jdk9/9/binaries/openjdk-9_linux-x64_bin.tar.gz[/url] . I have extracted this file under /home/ashik/Binary directory. I have added these two lines in .bashrc file under home directory:
Code: Select all
export JAVA_HOME=/home/ashik/Binary/jdk-9/bin/java

Code: Select all
export PATH=$PATH:/home/ashik/Binary/jdk-9/bin


When i'm running
Code: Select all
javac -version
in terminal then it's showing the openjdk-9 version number and when i'm compiling any *.java file using javac command then it's working fine. When I'm trying to run
Code: Select all
java -version
then it's still showing openjdk-8 version number which is per-installed on the system. I want to use openjdk-9 for both java and javac.

I found some solutions but i'm not sure that they are authentic or not. I found a solution here, https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps . I'm confused what does this code mean?
Code: Select all
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100
Is that secure to use? What is the preferred way to do that?
ashikuzzaman.ar
 
Posts: 11
Joined: 2017-09-09 03:50

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby stevepusser » 2017-10-04 21:01

Wow, another XY Java problem.

1. Install openjdk-9-jre or (openjdk-9 if you also want the JDK) from stretch-backports (see backports.org).
2. Install galternatives.
3. Use galternatives to set the various alts available for Java (more than a few) to use 9.
4. Profit!
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Krita 3.3.2.1, Pale Moon 27.6.0, Audacity 2.2.0, mpv 0.27.0, Corebird 1.7.1, Firefox 57.0, SMPlayer 17.11.2
User avatar
stevepusser
 
Posts: 8905
Joined: 2009-10-06 05:53

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby ashikuzzaman.ar » 2017-10-04 22:12

Oh thank you #stevepusser
Actually I knew about backports but I don't want to install from backports. What's the problem with my downloaded jdk ? If backports works fine then why not my jdk downloaded from the official site, http://openjdk.java.net/ ?

I have renamed the 'java' (binary file) to 'jaava' and after that when I typed 'java -version' then it's working very fine and showing the jdk-9 version number correctly. Most probably installed java binary are resisting 'java' for executing the desired java binary.

What is it's solution?
ashikuzzaman.ar
 
Posts: 11
Joined: 2017-09-09 03:50

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby stevepusser » 2017-10-05 17:34

Now that I think about it, I remember that installing the Debian packages automatically switch the alternatives for you. If you are asking for help from anyone that's done your way instead of the much better and easier Debian way, I think you are in for a long wait. In effect, this might be what you're doing in fixing things up your way: (click for full-sized gif)

Image
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Krita 3.3.2.1, Pale Moon 27.6.0, Audacity 2.2.0, mpv 0.27.0, Corebird 1.7.1, Firefox 57.0, SMPlayer 17.11.2
User avatar
stevepusser
 
Posts: 8905
Joined: 2009-10-06 05:53

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby ashikuzzaman.ar » 2017-10-05 19:24

I have a solution in my own way. Actually I wanted to know the reason and I think I figured that out.
I have just created a file under home directory as .bash_aliases and added the following line in this file.
Code: Select all
alias java='/home/ashik/Binary/jdk-9/bin/./java'


As far I realize, when I am typing java -version then that binary is calling from /usr/bin/ directory. There have two ways to fix that most probably and one of them is to uninstall openjre-8 which is installed by default and another one is to use update-alternatives command to force the system to use my desired jre path. I didn't do any of them because I was confused that if I did so then some default application might crush which is depended on java. Simply I have just created an alias for java and It's running well. By the way, Thanks #stevepusser for your support.

N.B. #stevepusser your gif image is not working. When I clicked It's not working as you described. :lol:
ashikuzzaman.ar
 
Posts: 11
Joined: 2017-09-09 03:50

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby GarryRicketson » 2017-10-05 21:08

Maybe your browser is not working, the image displays fine for me .
Including the full size when I click it.
"What we expect you have already Done"

Before doing anything, read the Debian documentation:
Debian Documentation
How to ask the smart way
Debian Foro Español
======================
For the Birds
User avatar
GarryRicketson
 
Posts: 4371
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Resolving class path for openjdk-9-jre downloaded versio

Postby stevepusser » 2017-10-06 01:43

Here's how I react when someone tries to get me to stop using my comfortable Linux in favor of Windows:

https://www.youtube.com/watch?v=A7B--yl54N8

I made a gif out of it, but a 2 MB mp4 became a 44 MB gif, so....no.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: Krita 3.3.2.1, Pale Moon 27.6.0, Audacity 2.2.0, mpv 0.27.0, Corebird 1.7.1, Firefox 57.0, SMPlayer 17.11.2
User avatar
stevepusser
 
Posts: 8905
Joined: 2009-10-06 05:53


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

fashionable