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

 

 

 

[Solved]install java on debian

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
dannyhmui
Posts: 32
Joined: 2017-05-10 20:41

[Solved]install java on debian

#1 Post by dannyhmui »

This is what I have done:

Code: Select all

sudo apt-get purge openjdk-\*
then downloaded the lastest java jdk1.8.0_131

Code: Select all

danny@DannyHome:~/Downloads$ ls
jdk-8u131-linux-x64.tar.gz
then did

Code: Select all

sudo mv jdk1.8.0_131/ /usr/lib/jvm/
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_131
danny@DannyHome:/usr/lib/jvm$ ls -all
total 28
drwxr-xr-x   3 root root  4096 Jun 22 21:12 .
drwxr-xr-x 167 root root 20480 Jun 17 20:13 ..
drwxr-xr-x   8 root root  4096 Mar 15 21:35 jdk1.8.0_131
danny@DannyHome:/usr/lib/jvm$ 
then I have added the following to end of line of /etc/profile
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_131
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

however, when I try to run java -version, I got?

Code: Select all

danny@DannyHome:/usr/lib/jvm$ java -version
bash: java: command not found
danny@DannyHome:/usr/lib/jvm$
can you guys help? it should show me correct java version
Last edited by dannyhmui on 2017-06-23 07:47, edited 1 time in total.

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: install java on debian

#2 Post by orythem27 »

I suggest using `make-jpkg` to generate deb packages from the oracle installer. It would be easier to manage afterwards.

0. Undo the above steps;

1. Download official package from oracle website. e.g. {jre,jdk}-8u131-linux-x64.tar.gz

2. Install `java-package` and use `make-jpkg` to generate deb packages;

3. Install generated deb packages.

dannyhmui
Posts: 32
Joined: 2017-05-10 20:41

Re: install java on debian

#3 Post by dannyhmui »

what java-package to install? so just apt-get install java-package?

then

Code: Select all

make-jpkg jdk-8u131-linux-x64.tar.gz
?

dannyhmui
Posts: 32
Joined: 2017-05-10 20:41

Re: install java on debian

#4 Post by dannyhmui »

sorry for the trouble, resolved:

Code: Select all

danny@DannyHome:~$ sudo update-alternatives --config java
[sudo] password for danny: 
There is 1 choice for the alternative java (providing /usr/lib/jvm).

  Selection    Path                                Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/jdk1.8.0_131/bin/java   1         auto mode
* 1            /usr/lib/jvm/jdk1.8.0_131/bin/java   1         manual mode

Press enter to keep the current choice[*], or type selection number: 0
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jdk1.8.0_131/bin/java because link group java is broken
update-alternatives: warning: not replacing /usr/lib/jvm with a link
danny@DannyHome:~$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
danny@DannyHome:~$ 

Post Reply