How to install JDK (Java Development Kit) on Linux
This tutorial will guide you on how to install JDK (Java Development Kit) on Linux. Since I use Centos 5.4 x86_64 in everyday life, this guide is showing you how to install JDK in Centos 5.4 64bit. It must work in any other Linux distro such as Slackware, Fedora, Ubuntu et cetera.
If you install a Linux OS, the developers usually already included a JVM to the system to run some programs that need Java. Mostly they included OpenJDK for the JVM.
But I don’t like to use OpenJDK because some Java platform like JavaFX will not run using OpenJDK.
UPDATE! Java SE 6 (JDK 1.6) Update 24 (file name: jdk-6u24-linux-i586.bin) is now available. You can download the file from Java SE Downloads page. Java SE 7 (JDK 1.7) Binary Snapshot build b132 also has been released. If you want to download and install the Java SE 7, you can get the file fromJava SE 7 download page with the file name jdk-7-ea-bin-b132-linux-i586-03_mar_2011.bin. This tutorial should be applicable for those version.
1. Download the JDK
The JDK can be downloaded from its official website. At the time this tutorial was written, the JDK version is JDK 6 Update 17. Click the Download button then you will be forwarded to Java SE Download page. You can select the Java platform to suit your system.
Since I use x86_64 of Linux, I choose ‘Linux x64′ for the platform. Then click ‘Continue’ button. You can skip for the ‘Log in for Downloads’ optional window. Then select from the available files.
Choose not the ‘rpm’ file because we will install the JDK in a folder as we want to.
2. After the download is complete, unpack the file by executing it.
First you have to make it executable.
[fuad@centos Downloads]$ chmod +x jdk-6u17-linux-x64.bin
[fuad@centos Downloads]$ ./jdk-6u17-linux-x64.bin inflating: jdk1.6.0_17/README.html
creating: jdk1.6.0_17/include/
inflating: jdk1.6.0_17/include/jni.h
creating: jdk1.6.0_17/include/linux/
inflating: jdk1.6.0_17/include/linux/jawt_md.h
inflating: jdk1.6.0_17/include/linux/jni_md.h
inflating: jdk1.6.0_17/include/jvmti.h
inflating: jdk1.6.0_17/include/jawt.h
inflating: jdk1.6.0_17/include/jdwpTransport.h
inflating: jdk1.6.0_17/include/classfile_constants.h
inflating: jdk1.6.0_17/COPYRIGHT
Creating jdk1.6.0_17/jre/lib/rt.jar
Creating jdk1.6.0_17/jre/lib/jsse.jar
Creating jdk1.6.0_17/jre/lib/charsets.jar
Creating jdk1.6.0_17/lib/tools.jar
Creating jdk1.6.0_17/jre/lib/ext/localedata.jar
Creating jdk1.6.0_17/jre/lib/plugin.jar
Creating jdk1.6.0_17/jre/lib/javaws.jar
Creating jdk1.6.0_17/jre/lib/deploy.jar Java(TM) SE Development Kit 6 successfully installed. Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Sun products, services and training
* Access to early releases and documentation Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK will be presented. If you do not register, none of
this information will be saved. You may also register your
JDK later by opening the register.html file (located in
the JDK installation directory) in a browser. For more information on what data Registration collects and
how it is managed and used, see: http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html Press Enter to continue..... Done.
A folder ‘jdk1.6.0_17′ will be created.
3. Move the ‘jdk1.6.0_17′ folder to a safe place
We will move this folder to a place as you want to. You can move it to /opt folder, leave it in this directory or to anywhere in the system. I prefer to move this folder to /usr/local. So move it there.
[fuad@centos Downloads]$ sudo mv jdk1.6.0_17 /usr/local/
Here in the /usr/local/ directory, we will create a symbolic link to jdk1.6.0_17 named as ‘java’
[fuad@centos Downloads]$ cd /usr/local/
[fuad@centos local]$ sudo ln -s jdk1.6.0_17 java
Now the JDK is installed in /usr/local/jdk1.6.0_17 and linked to /usr/local/java.
We need to add /usr/local/java/bin folder to the system PATH. If it is only for your account, add it in .bash_profile file in you home directory. In Slackware, it should be in .profile file. To make it system wide environment, add it in the /etc/profile.
Edit a line in .bash_profile to be similar like below:
PATH=$PATH:$HOME/bin:/usr/local/java/bin
This way the PATH will be automatically set at boot time.
You can also set the PATH immediately by using a command below:
$ export PATH=$PATH:/usr/local/java/bin
Now you can call java directly in your shell:
$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)
4. Upgrade to the latest version
If there is a new JDK version released by Sun/Oracle and you want to upgrade to the latest version, you can simply follow the steps above. Except for the third step, after moving the new JDK version to /usr/local/ folder, you need to remove the existing ‘java’ folder in the /usr/local/ directory and re-create the symbolic link again.
For example, today on May 18th, 2010, I checked to the java.sun.com website that the current latest version of the JDK is JDK 6 Update 20. So after following step 1 and 2, we remove the ‘java’ folder and re-create the symbolic link again to the ‘java’ folder.
$ sudo rm -rf java
$ sudo ln -s jdk1.6.0_20 java
To make sure it has been successfully upgraded, you can check the current java version.
$ java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)
How to install JDK (Java Development Kit) on Linux的更多相关文章
- jdk (Java Development Kit)
JDK是 Java 语言的软件开发工具包,主要用于移动设备.嵌入式设备上的java应用程序.JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具. JD ...
- eclipse解压后启动弹出A Java Runtime Evironment(JRE) or Java Development Kit(JDK)....
系统环境:win7 64bit JDK:jdk-7u79-windows-x64 Eclipse:eclipse-jee-helios-win32 启动eclipse:弹出A Java Runtime ...
- ubuntu myeclipse 启动时提示 A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avail ....
jdk已经安装过但是启动eclipse时提示“A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avail ...
- Linux 下报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must解决方案
一.报错环境:在Linux mint下,前几天还用得很好的的eclipse,今天开机不知为什么这样. Linux 下报错:A Java RunTime Environment (JRE) or Jav ...
- A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/
linux系统下jdk是已经安装好的情况之下软件出现 A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be av ...
- ubuntu 打开eclipse出现A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be ... 解决方法(转载)
原创作者:http://www.cnblogs.com/jerome-rong/archive/2013/02/19/2916608.html Java RunTime Environment (JR ...
- eclipse 启动问题Eclipse启动时报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No java virtual machine was found after searching the following locat
从其他人直接复制的环境导致的问题. 正常双击出现当前异常,以管理员权限启动可以正常启动. ---------------------------Eclipse--------------------- ...
- Eclipse启动错误:A Java Runtime Environment(JRE) or Java Development Kit(JDK) must be available……
确保Jdk,Jre都安装完成并且环境变量配置无误的情况下,自动Ecplise报错如下: A Java Runtime Environment (JRE) or Java Development Kit ...
- JDK(Java Development Kit)内置常用自带工具一览(转)
注意:可能随着JDK的版本升级,工具也会随着增多. JDK(Java Development Kit)是Java程序员最核心的开发工具,没有之一. JDK是一个功能强大的Java开发套装,它不仅仅为我 ...
随机推荐
- UML中的六种关系的比较与学习
通过不断的学习并绘制UML图,整个画图的过程中深刻体会到其核心部分还是理解事物之间的关系,总结六大关系来深入学习,主要关系有六种:继承.实现.依赖.关联.聚合.组合. 区别于联系: 1 ...
- Halcon学习笔记之缺陷检测(二)
例程:detect_indent_fft.hdev 说明:这个程序展示了如何利用快速傅里叶变换(FFT)对塑料制品的表面进行目标(缺陷)的检测,大致分为三步: 首先,我们用高斯滤波器构造一个合适的滤波 ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
- vi之跳到指定行
vi里怎样跳转到某一指定行 输入 :行号 :$跳到最后一行 gg跳到第一行.
- 【转载】struct和typedef struct彻底明白了
分三块来讲述: 1 首先://注意在C和C++里不同 在C中定义一个结构体类型要用typedef: typedef struct Student { int a; }Stu; 于是在声明变量的时候就可 ...
- iOS开发之ARC&MRC混用
Xcode 项目中我们可以使用 ARC 和非 ARC 的混合模式. 如果你的项目使用的非 ARC 模式,则为 ARC 模式的代码文件加入 -fobjc-arc 标签. 如果你的项目使用的是 ARC 模 ...
- PHP之Error与Logging函数讲解
PHP Error 和 Logging 简介 error 和 logging 函数允许你对错误进行处理和记录. error 函数允许用户定义错误处理规则,并修改记录错误的方式. logging 函数允 ...
- LightOj 1065 - Number Sequence (矩阵快速幂,简单)
题目 和 LightOj 1096 - nth Term 差不多的题目和解法,这道相对更简单些,万幸,这道比赛时没把模版给抽风坏. #include<stdio.h> #include&l ...
- 【好玩的应用】QQ连连看辅助工具
自己学了这么久的C语言,但没有写出过什么可以用的东西来,总觉得心里不爽.这几天实在是不想干正事,在网上瞎逛逛,结果发现有人写了连连看的外挂.顿时觉得这很有意思啊.于是把代码下载下来,捣鼓了捣鼓.发现还 ...
- [SQL Server 系] T-SQL数据库的创建与修改
创建数据库 USE master; GO CREATE DATABASE ToyUniverse ON ( NAME = ToyUniverse_Data, FILENAME = 'F:\Projec ...