Java/FAQ

From FedoraProject

< Java(Difference between revisions)
Jump to: navigation, search
(A program uses classes which are not supported by GCJ. How can I port it so it will work?)
(How can I assist with the development of GCJ without programming?)
(10 intermediate revisions by 3 users not shown)
Line 7: Line 7:
 
=== What is the Java environment in Fedora? ===
 
=== What is the Java environment in Fedora? ===
  
OpenJDK 6 is the default Java environment since Fedora 9.  It is Sun Java under a free and open source license, and there are runtime and development packages.
+
[http://openjdk.java.net OpenJDK 7] is the default Java environment since Fedora 17.  It is Oracle(formerly Sun) Java under a free and open source license, and there are runtime and development packages.
  
 
There is also an alternative Java environment in Fedora that has three components: the [http://gcc.gnu.org/java/ GNU Java]  runtime ("libgcj"), the [[Eclipse]]  Java compiler ("ecj"), and a set of wrappers and links ("java-gcj-compat") that present the runtime and compiler to the user in the same way as other Java environments are presented.
 
There is also an alternative Java environment in Fedora that has three components: the [http://gcc.gnu.org/java/ GNU Java]  runtime ("libgcj"), the [[Eclipse]]  Java compiler ("ecj"), and a set of wrappers and links ("java-gcj-compat") that present the runtime and compiler to the user in the same way as other Java environments are presented.
Line 19: Line 19:
 
=== I didn't get Java at install time, but I want to install it now. How do I do that? ===
 
=== I didn't get Java at install time, but I want to install it now. How do I do that? ===
  
On Fedora 9+ the OpenJDK 6 runtime and development packages are installed by default during any large-media install, such as from the Fedora DVD.
+
On Fedora 17+ the OpenJDK 7 runtime and development packages are installed by default during any large-media install, such as from the Fedora DVD.
  
If installing from a live image, such as a live CD or USB flash drive, add the OpenJDK 6 runtime after the install:
+
If installing from a live image, such as a live CD or USB flash drive, add the OpenJDK 7 runtime after the install:
  
 
* To install with the graphical package manager, follow ''System > Administration > Add/Remove Software'' and use search to find the package(s) to install.
 
* To install with the graphical package manager, follow ''System > Administration > Add/Remove Software'' and use search to find the package(s) to install.
Line 27: Line 27:
 
* To install from the command line:
 
* To install from the command line:
 
<pre>
 
<pre>
su -c "yum install java-1.6.0-openjdk"
+
su -c "yum install java-1.7.0-openjdk"
 
</pre>
 
</pre>
This package contains just the Java Runtime Environment. To develop Java programs, install the <code>java-1.6.0-openjdk-devel</code> package. Install all the OpenJDK 6 packages, including the API documentation, by using the wildcard <code>java-1.6.0-openjdk*</code>.
+
This package contains just the Java Runtime Environment. To develop Java programs, install the <code>java-1.7.0-openjdk-devel</code> package. Install all the OpenJDK 7 packages, including the API documentation, by using the wildcard <code>java-1.7.0-openjdk*</code>.
 
+
On Fedora 8 the OpenJDK 7 runtime and development packages are installed by default during any large-media install, such as from the Fedora 8 DVD, under the name IcedTea. If installing from a live image, follow the above instructions but replace <code>1.6.0-openjdk</code> with <code>1.7.0-icedtea</code>.
+
  
 
To install the <code>gcj</code>-related packages:
 
To install the <code>gcj</code>-related packages:
Line 38: Line 36:
 
* To install from the command line:
 
* To install from the command line:
 
<pre>
 
<pre>
su -c "yum install java-1.4.2-gcj-compat"
+
su -c "yum install java-1.5.0-gcj-compat"
 
</pre>
 
</pre>
This package contains just the Java Runtime Environment. To develop Java programs, install the <code>java-1.4.2-gcj-compat-devel</code> package. Install all the OpenJDK 6 packages, including the API documentation, by using the wildcard <code>java-1.4.2-gcj-compat*</code>.
+
This package contains just the Java Runtime Environment. To develop Java programs, install the <code>java-1.5.0-gcj-compat-devel</code> package. Install all the GCJ packages, including the API documentation, by using the wildcard <code>java-1.5.0-gcj-compat*</code>.
  
 
Refer to the [http://docs.fedoraproject.org/yum/ Software Management Guide]  for more information.
 
Refer to the [http://docs.fedoraproject.org/yum/ Software Management Guide]  for more information.
Line 60: Line 58:
 
=== Are parts of the Java platform known not to exist or work properly in Fedora? ===
 
=== Are parts of the Java platform known not to exist or work properly in Fedora? ===
  
No, everything is there and works just fine, if you're using the recommended OpenJDK 6, that is. GNU Java misses a lot of stuff as noted below in "Tool Support".
+
No, everything is there and works just fine, if you're using the recommended OpenJDK 7, that is. GNU Java misses a lot of stuff as noted below in "Tool Support".
  
 
==== Java Language ====
 
==== Java Language ====
Line 76: Line 74:
 
==== Tool Support ====
 
==== Tool Support ====
  
* OpenJDK 6 features every known Java tool from Oracle's reference Java implemenation
+
* OpenJDK 7 features every known Java tool from Oracle's reference Java implemenation
  
 
* The following JDK 1.5 tools are missing from libgcj: <code>apt</code>, <code>ControlPanel</code>, <code>extcheck</code>, <code>HtmlConverter</code>, <code>idlj</code>, <code>javap</code>, <code>java-rmi.cgi</code>, <code>javaws</code>, <code>jconsole</code>, <code>jdb</code>, <code>jinfo</code>, <code>jmap</code>, <code>jps</code>, <code>jsadebugd</code>, <code>jstack</code>, <code>jstat</code>, <code>jstatd</code>, <code>kinit</code>, <code>klist</code>, <code>ktab</code>, <code>native2ascii</code>, <code>orbd</code>, <code>pack200</code>, <code>policytool</code>, <code>rmid</code>, <code>serialver</code>, <code>servertool</code>, <code>tnameserv</code> and <code>unpack200</code>
 
* The following JDK 1.5 tools are missing from libgcj: <code>apt</code>, <code>ControlPanel</code>, <code>extcheck</code>, <code>HtmlConverter</code>, <code>idlj</code>, <code>javap</code>, <code>java-rmi.cgi</code>, <code>javaws</code>, <code>jconsole</code>, <code>jdb</code>, <code>jinfo</code>, <code>jmap</code>, <code>jps</code>, <code>jsadebugd</code>, <code>jstack</code>, <code>jstat</code>, <code>jstatd</code>, <code>kinit</code>, <code>klist</code>, <code>ktab</code>, <code>native2ascii</code>, <code>orbd</code>, <code>pack200</code>, <code>policytool</code>, <code>rmid</code>, <code>serialver</code>, <code>servertool</code>, <code>tnameserv</code> and <code>unpack200</code>
Line 82: Line 80:
 
=== What about running Java applets in the browser? ===
 
=== What about running Java applets in the browser? ===
  
You'll need the <code>java-1.6.0-openjdk-plugin</code>. If you've installed OpenJDK as a feature from a large-media distribution such as the Fedora DVD you're all set.
+
Shipped since Fedora 15.
Otherwise you'll have to install it manually:
+
  
 
<pre>
 
<pre>
su -c "yum install java-1.6.0-openjdk-plugin"
+
su -c "yum install icedtea-web"
 
</pre>
 
</pre>
  
This plugin is known to work in most major browsers(Firefox, Chromium, etc).
+
=== How can I assist the development of OpenJDK ===
 +
 
 +
Hack on the JDK itself, right here in the growing OpenJDK Community: Browse the code on the web, get a source bundle or clone a Mercurial repository to make a local copy, learn how to build and hack on the code with the NetBeans IDE, and [http://openjdk.java.net/contribute/ contribute a patch to fix a bug], enhance an existing component, or define a new feature.
  
 
=== A program uses classes which are not supported by GCJ. How can I port it so it will work? ===
 
=== A program uses classes which are not supported by GCJ. How can I port it so it will work? ===
Line 105: Line 104:
 
=== How can I assist with the development of GCJ without programming? ===
 
=== How can I assist with the development of GCJ without programming? ===
  
The most helpful thing you can do is try your applets and applications on Fedora's free runtime and file good bug reports when they don't work.  When filing bugs against Fedora's runtime, file them against the java-1.4.2-gcj-compat component in [http://bugzilla.redhat.com/ Red Hat Bugzilla]  and the Fedora GCJ/libgcj maintainers will file and fix them upstream.
+
The most helpful thing you can do is try your applets and applications on Fedora's free runtime and file good bug reports when they don't work.  When filing bugs against Fedora's runtime, file them against the java-1.5.0-gcj-compat component in [http://bugzilla.redhat.com/ Red Hat Bugzilla]  and the Fedora GCJ/libgcj maintainers will file and fix them upstream.
  
 
=== How do I get stack traces from Java programs when filing a bug report? ===
 
=== How do I get stack traces from Java programs when filing a bug report? ===
Line 123: Line 122:
 
-->
 
-->
  
 +
=== Can I run Oracle Java on Fedora? ===
 +
 +
You sure can, however, we recommend you to try OpenJDK first and switch to Oracle Java only if you experience problems with the OpenJDK.
  
 +
Oracle Java can be downloaded from [http://www.java.com/en/download/ here] as an RPM package. You can use afterwards the <code>alternatives</code> program to toggle
 +
between different Java runtime environments, compilers, etc.
  
 
= See Also =
 
= See Also =

Revision as of 07:06, 14 August 2013

Contents

Java FAQ

Questions about the Java environment running on Fedora.

General

What is the Java environment in Fedora?

OpenJDK 7 is the default Java environment since Fedora 17. It is Oracle(formerly Sun) Java under a free and open source license, and there are runtime and development packages.

There is also an alternative Java environment in Fedora that has three components: the GNU Java runtime ("libgcj"), the Eclipse Java compiler ("ecj"), and a set of wrappers and links ("java-gcj-compat") that present the runtime and compiler to the user in the same way as other Java environments are presented.

Doesn't libgcj need compiled native code? I just want to run jarfiles!

libgcj does have the ability to run jarfiles. The java command on your Fedora box executes Java bytecode similarly to any other Java runtime.

You are, however, strongly encouraged to use the OpenJDK runtime as its far more robust and feature complete. Eventually at some point OpenJDK will replace GNU Java completely.

I didn't get Java at install time, but I want to install it now. How do I do that?

On Fedora 17+ the OpenJDK 7 runtime and development packages are installed by default during any large-media install, such as from the Fedora DVD.

If installing from a live image, such as a live CD or USB flash drive, add the OpenJDK 7 runtime after the install:

  • To install with the graphical package manager, follow System > Administration > Add/Remove Software and use search to find the package(s) to install.
  • To install from the command line:
su -c "yum install java-1.7.0-openjdk"

This package contains just the Java Runtime Environment. To develop Java programs, install the java-1.7.0-openjdk-devel package. Install all the OpenJDK 7 packages, including the API documentation, by using the wildcard java-1.7.0-openjdk*.

To install the gcj-related packages:

  • With the graphical package manager, go to Applications > Add/Remove Software and use search to find the package(s) to install.
  • To install from the command line:
su -c "yum install java-1.5.0-gcj-compat"

This package contains just the Java Runtime Environment. To develop Java programs, install the java-1.5.0-gcj-compat-devel package. Install all the GCJ packages, including the API documentation, by using the wildcard java-1.5.0-gcj-compat*.

Refer to the Software Management Guide for more information.

Fedora's Java environment does not provide the functionality I require. Can I install another?

The JPackage Project has packages for a variety of Java environments, both free and proprietary. These packages are designed so that more than one may be installed simultaneously. The Java environment in Fedora is fully compatible with this system.

Installing a JPackage Java environment is described in detail in JpackageJava .

Java environments other than from JPackage are likely to interfere with Fedora's Java environment and their use is not recommended.

Usage

Where is everything?

Java packages in Fedora are in the main based on and compatible with those of the JPackage Project . Their packaging infrastructure and policy documentation is included in full in the jpackage-utils package. The main things you probably want to know, however, are that the commands (java, javac, jar, etc) are on the system path, the main jar repository is /usr/share/java and the extensions jar repository is /usr/share/java-ext

Are parts of the Java platform known not to exist or work properly in Fedora?

No, everything is there and works just fine, if you're using the recommended OpenJDK 7, that is. GNU Java misses a lot of stuff as noted below in "Tool Support".

Java Language

OpenJDK is mostly a rebranded version of Oracle's JDK, so it naturally implements everything there is to implement. There are a couple of differences though, concerning parts of Java's code to which Oracle does not own the copyright. Most notably the Swing implementation is using a different rendering engine and this is know to cause some issues.

As far as GNU Classpath is concerned - except for these few items, most of the language has been implemented.

  • Assertions are mostly implemented, but no-one has yet provided a way to activate them!
  • None of the Java language features that are new in Java 1.5 are implemented yet

Tool Support

  • OpenJDK 7 features every known Java tool from Oracle's reference Java implemenation
  • The following JDK 1.5 tools are missing from libgcj: apt, ControlPanel, extcheck, HtmlConverter, idlj, javap, java-rmi.cgi, javaws, jconsole, jdb, jinfo, jmap, jps, jsadebugd, jstack, jstat, jstatd, kinit, klist, ktab, native2ascii, orbd, pack200, policytool, rmid, serialver, servertool, tnameserv and unpack200

What about running Java applets in the browser?

Shipped since Fedora 15.

su -c "yum install icedtea-web"

How can I assist the development of OpenJDK

Hack on the JDK itself, right here in the growing OpenJDK Community: Browse the code on the web, get a source bundle or clone a Mercurial repository to make a local copy, learn how to build and hack on the code with the NetBeans IDE, and contribute a patch to fix a bug, enhance an existing component, or define a new feature.

A program uses classes which are not supported by GCJ. How can I port it so it will work?

If the full names of the classes in question start with sun. or com.sun., please see http://developer.classpath.org/mediation/ClasspathMigration

Alternatively, as noted several times already - favor the OpenJDK runtime. Otherwise, see the next question.

How can I assist with the development of GCJ?

If you are not a programmer, or you are stopped by legal reasons from contributing patches to GCJ, see the next question.

Most GCJ development work (class libraries, tools) is done in GNU Classpath . GCJ-specific work (compiler, CNI) is done in GCC . All upstream bug reports are filed in GCC Bugzilla .

How can I assist with the development of GCJ without programming?

The most helpful thing you can do is try your applets and applications on Fedora's free runtime and file good bug reports when they don't work. When filing bugs against Fedora's runtime, file them against the java-1.5.0-gcj-compat component in Red Hat Bugzilla and the Fedora GCJ/libgcj maintainers will file and fix them upstream.

How do I get stack traces from Java programs when filing a bug report?

See JavaStackTraces

Why are my executable JAR files opened instead of being executed?

The default action for .jar files is to treat them as ordinary .zip files. Two ways to fix this:

  • Register a binfmt for .jar (see /usr/share/doc/kernel-doc-*/Documentation/java.txt for details)
  • Change the default action in nautilus, or whatever file manager you use. In nautilus, I think you can do this by: right-click on the .jar file, choose Properties, choose Open With, click Add, click Use a custom command, and type in xterm -e java -jar

Can I run Oracle Java on Fedora?

You sure can, however, we recommend you to try OpenJDK first and switch to Oracle Java only if you experience problems with the OpenJDK.

Oracle Java can be downloaded from here as an RPM package. You can use afterwards the alternatives program to toggle between different Java runtime environments, compilers, etc.

See Also