Install Java in Linux(Ubuntu/Debian)

Install Java in Linux (Ubuntu / Debian)

This manual is to help install java (jdk) in Ubuntu / Debian Linux. 

Previously we discussed about how java’s installation has evolved over a period, then I promised to write an article on installing java on Linux. 

Yes I love Linux!

Before install you should be aware of couple of things.

  1. Which package I need to install
  2. Is that package already installed in my linux box

Which Package to Install?

‘Generally’ we use sun’s (oracle) jdk. 

If you do not have precondition on which package, then use sun’s package. 

FOSS equivalent alternative for sun JDK is openjdk.

To know the list of jdk packages available for you to install, use the following command:

$ dpkg-query -l '*jdk*'

Is java already installed in my linux?

$ which java 

or

$ java -version

Above two commands is the easiest way to identify if java is installed in your linux. 

But this will work only if you have installed jdk using standard means and the path are setup correctly.


Otherwise,

  • If you know the exact package name, you can use following command:
$ dpkg-query -W -f='${Status} ${Version}\n' sun-java6-jdk

in the above command, sun-java6-jdk is the package name.

If your jdk is not installed you will get the following response:
“No packages found matching sun-java6-jdk.”

or you can use the following command to get a detailed output

$ dpkg -s sun-java6-jdk

Java Installed but path not set or don’t know the path

Use the following commands to know the path of jdk installation

 $ sudo updatedb
$ locate java 

Install Jdk

As of the time of writing this article sun’s package is not available in the partner repositories. 

Therefore you will not be able to do live installation using defalut repositories.

Either, you need to add additional repository to your list or download package from available site and install it offline.

Method 1: Live Install

You need a live internet connection. Run the following commands sequentially.

$ sudo apt-get install python-software-properties

$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6

$ sudo apt-get update

$ sudo apt-get install sun-java6-jdk

Method 2: Download and Install

http://archive.canonical.com/pool/partner/s/sun-java6/

This url has list of Sun’s packages available. Download the appropriate package and use the following command:

 $ sudo dpkg -i package.deb 

After this, your JAVA_HOME will be:

JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.06"

Wishing you Merry Christmas!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值