个人工具

“UbuntuHelp:Java”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
第5行: 第5行:
 
Sun Microsystems developed Java, which is many things depending on who you ask.  It is a language, and an execution environment and probably many more things.  On this page Java refers to the software that executes programs compiled to Java byte codes (akin to machine language).
 
Sun Microsystems developed Java, which is many things depending on who you ask.  It is a language, and an execution environment and probably many more things.  On this page Java refers to the software that executes programs compiled to Java byte codes (akin to machine language).
 
=== Running Java under Ubuntu ===
 
=== Running Java under Ubuntu ===
In order to run Java programs and Java applets, you must have a Java environment installed. The GCJ flavor of Java is installed as default, and is usually fine for most purposes. If it is not installed, [[UbuntuHelp:JavaInstallation|JavaInstallation]] describes how to install some opensource flavors of Java.  You may, however, have a need to run the Sun flavor of Java if something does not work correctly.
+
In order to run Java programs, you must have a Java run time environment (JRE) installed. To run Java web applets in your browser, you additionally need a plugin for your browser, which is not installed by default.  To use Java Web Start applications, no browser plugin is necessary. The default flavor of JRE installed is defined by the package default-jre. Currently, it is openjdk-6-jre, which is mostly derived from the Sun JRE.
To get Sun Java under Ubuntu 7.04 or later running on Intel or PowerPC platform, you should enable the Universe repository in Add/Remove programs, and install either the <code><nowiki>openjdk-6-jre</nowiki></code> package or the <code><nowiki>sun-java6-bin</nowiki></code> package.  (Note:  PowerPC version is slow).
+
To run Java applets using the plugin corresponding to OpenJDK, you must install the package <code><nowiki>icedtea6-plugin</nowiki></code> .
To get Sun Java under Ubuntu 6.06 or 6.10 running on Intel x86 platform, you should enable the Universe repository in Add/Remove programs, and install the <code><nowiki>sun-java5-bin</nowiki></code> package.  
+
Some Java applications may experience problems or worse problems under other JREs. Trial may be necessary.
 +
[[UbuntuHelp:JavaInstallation|JavaInstallation]] describes how to install some open source flavors of Java.
 +
To get Sun closed source Java under Ubuntu 7.04 or later running on Intel or PowerPC platform, enable the Universe repository in Add/Remove programs, and install the <code><nowiki>sun-java6-jre</nowiki></code> and <code><nowiki>sun-java6-plugin</nowiki></code> packages.
 +
For applet support in the browser, install <code><nowiki>sun-java6-plugin</nowiki></code> as well (Warning: PowerPC version is slow, Warning: sun-java6 incorrectly sizes fonts in the GTK Look And Feel).
 
Note: The same commands will work under Xubuntu/Kubuntu (using Add/Remove or the Adept Package Installer).
 
Note: The same commands will work under Xubuntu/Kubuntu (using Add/Remove or the Adept Package Installer).
 
=== Choosing the default Java to use ===
 
=== Choosing the default Java to use ===

2010年5月19日 (三) 23:00的最新版本

Please do not make any edits to this article. Its contents are currently under review and being merged with the Ubuntu Server Guide. To find the Ubuntu Server Guide related to your specific version, please go to: https://help.ubuntu.com/ and click on Ubuntu Server Guide Sun Microsystems developed Java, which is many things depending on who you ask. It is a language, and an execution environment and probably many more things. On this page Java refers to the software that executes programs compiled to Java byte codes (akin to machine language).

Running Java under Ubuntu

In order to run Java programs, you must have a Java run time environment (JRE) installed. To run Java web applets in your browser, you additionally need a plugin for your browser, which is not installed by default. To use Java Web Start applications, no browser plugin is necessary. The default flavor of JRE installed is defined by the package default-jre. Currently, it is openjdk-6-jre, which is mostly derived from the Sun JRE. To run Java applets using the plugin corresponding to OpenJDK, you must install the package icedtea6-plugin . Some Java applications may experience problems or worse problems under other JREs. Trial may be necessary. JavaInstallation describes how to install some open source flavors of Java. To get Sun closed source Java under Ubuntu 7.04 or later running on Intel or PowerPC platform, enable the Universe repository in Add/Remove programs, and install the sun-java6-jre and sun-java6-plugin packages. For applet support in the browser, install sun-java6-plugin as well (Warning: PowerPC version is slow, Warning: sun-java6 incorrectly sizes fonts in the GTK Look And Feel). Note: The same commands will work under Xubuntu/Kubuntu (using Add/Remove or the Adept Package Installer).

Choosing the default Java to use

Just installing new Java flavours does not change the default Java pointed to by /usr/bin/java. You must explicitly set this:

  • Open a Terminal window
  • Run sudo update-java-alternatives -l to see the current configuration and possibilities.
  • Run sudo update-java-alternatives -s XXXX to set the XXX java version as default. For Sun Java 6 this would be sudo update-java-alternatives -s java-6-sun
  • Run java -version to ensure that the correct version is being called.

You can also use the following command to interactively make the change;

  • Open a Terminal window
  • Run sudo update-alternatives --config java
  • Follow the onscreen prompt