返回介绍

Installing Java

发布于 2025-02-22 22:20:10 字数 3032 浏览 0 评论 0 收藏 0

In this part of the JEE tutorial series, we will install the Java Development Kit (JDK). The JDK is a software development kit used to create Java applications. If we need to run Java applications, we only need the Java Runtime Environment (JRE). If we want to create Java applications, we also need the JDK. The JDK also includes JRE. Primary components of the Java Development Kit are Java compiler, launcher, documentation generator, debugger, disassembler, archiver.

There are three basic Java editions.

  • Java SE - Java Standard Edition
  • Java EE - Java Enterprise Edition
  • Java ME - Java Micro Edition

If we download the JDK we can create Java SE applications. These are basically command line applications a Java Swing GUI applications. Java EE is used to create enterprise applications. The Java ME is used to create mobile applications. For both of them, we need to install additional libraries. Java EE is the target of our tutorials.

Steps

These are the steps to install the latest JDK on Linux. When I write these words it is JDK 6 Update 3.

  1. go to http://java.sun.com/
  2. select menu downloads - Java SE
  3. click on the download button of the latest JDK version
  4. accept licence agreement
  5. download the the appropriate version of java, Linux self-extracting file, 65.40 MB
  6. sudo chmod +x jdk-6u3-linux-i586.bin
  7. ./jdk-6u3-linux-i586.bin
  8. Do you agree to the above license terms? [yes or no] yes
  9. mv jdk1.6.0_03/ installdir
$ export PATH=$PATH:/home/vronskij/bin/jdk1.6.0_03/bin/

We add the bin directory to the PATH variable. On my computer the path to the Java bin directory is /home/vronskij/bin/jdk1.6.0_03/bin/ .

$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

We verify the installed version of java. Now let's create a simple Java console application. Launch your favourite text editor and write down the following code.

/* Console.java */

public class Console {

  public static void main(String[] args) {
    System.out.println("Java console application");
  }
}

This sample program will print text on the console window.

$ javac Console.java
$ ls
Console.class  Console.java  Console.java~
$ java Console
Java console application

We compile the source code with the javac command. Then we launch the program with the java command.

export JAVA_HOME=/home/vronskij/bin/jdk1.6.0_03/bin/

We set up the JAVA_HOME variable to point to our JDK. This is for other applications like ant or Netbeans, so that they know, where the Java has been installed.

In this part of the JEE tutorial, we covered Java installation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文