Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Resolving class path for openjdk-9-jre downloaded version

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
ashikuzzaman.ar
Posts: 11
Joined: 2017-09-09 03:50

Resolving class path for openjdk-9-jre downloaded version

#1 Post by ashikuzzaman.ar »

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 download.java.net/java/GA/jdk9/9/binari ... bin.tar.gz . 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/ ... 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?

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

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

#2 Post by stevepusser »

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!
MX Linux packager and developer

ashikuzzaman.ar
Posts: 11
Joined: 2017-09-09 03:50

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

#3 Post by ashikuzzaman.ar »

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?

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

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

#4 Post by stevepusser »

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
MX Linux packager and developer

ashikuzzaman.ar
Posts: 11
Joined: 2017-09-09 03:50

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

#5 Post by ashikuzzaman.ar »

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:

User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

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

#6 Post by GarryRicketson »

Maybe your browser is not working, the image displays fine for me .
Including the full size when I click it.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

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

#7 Post by stevepusser »

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.
MX Linux packager and developer

Post Reply