Java is an object-oriented programming language developed by Sun
Microsystems in the early 1990s. Java applications are compiled to
bytecode, which at runtime is either interpreted or compiled to native
machine code for execution.
The language itself derives much of its syntax
from C and C++ but has a simpler object model and fewer low-level
facilities. JavaScript, a scripting language, shares a similar name and
has similar syntax, but is not directly related to Java.
Currently Ubuntu has the following Java packages
sun-java6-bin - Contains the binaries
sun-java6-demo - Contains demos and examples
sun-java6-doc - Contains the documentation
sun-java6-fonts - Contains the Lucida TrueType fonts from the JRE
sun-java6-jdk - Contains the metapackage for the JDK
sun-java6-jre - Contains the metapackage for the JRE
sun-java6-plugin - Contains the plug-in for Mozilla-based browsers
sun-java6-source - Contains source files for the JDK
Installing the Java Runtime Environment
First you need to check multiverse repository enabled or not after
that open a terminal window. Since you are going to be installing the
JRE and the web browser plug-in, you’ll be using the following command
from a terminal
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
Once it downloads the packages and begins the installation, you’ll
get a screen that contains the Sun Operating System Distributor License
for Java and hit Enter to continue. You’ll see a dialog that asks you
if you agree with the DLJ license terms. Select Yes, and hit Enter; the
JRE will finish installing.
Testing Java Runtime Environment
You’ll want to confirm that your system is configured properly for Sun’s JRE. This is a two-step process.
First, check that the JRE is properly installed by running the following command from a terminal.
java -version
You should get similar output
java version “1.6.0″
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
Testing Java Plugin for Firefox
open Firefox and typing about:plugins in the address bar and check for java plugin
此篇文章为[JAVA开发专题]第一篇,内容为“给Ubuntu配置JAVA环境“。这次的JAVA专题是给想要在
Ubuntu下进行和从事JAVA软件开发的用户参考的,也同时给想要从Windows下的JAVA开发转移到Ubuntu下开发的用户参考。废话不多说
了,正文开始:
操作系统版本:Ubuntu 7.10 Gutsy
JAVA版本:JAVA 6
在Ubuntu下安装JAVA虚拟机和SDK(开发包)是非常轻松容易的:
联网的情况下在终端下输入命令
$sudo apt-get install sun-java6-jre sun-java6-sdk
这条命令就可以帮助下载并安装JAVA6了,顺便再给浏览器安装JAVA支持:
$sudo apt-get install sun-java6-plugin
安装完这三个之后还需要写入系统变量:
$sudo gedit /etc/environment
在文本编辑器里写入下面两行内容:
CLASSPATH=.:/usr/lib/jvm/java-6-sun/lib
JAVA_HOME=/usr/lib/jvm/java-6-sun
还要将系统虚拟机的优先顺序也调整一下:
$sudo gedit /etc/jvm
在文本编辑器里将下面一句写在最顶部:
/usr/lib/jvm/java-6-sun
接下来在终端中输入命令:
$java -version
终端应该返回如下字样:
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
这就说明JAVA环境已经建立好了,你可以用文本编辑器写一个JAVA HelloWorld!程序执行一下javac编译并java来解释执行看看效果。