[fedora-java] Re: Java on Fedora faq

Robin Green greenrd at presidium.org
Tue Jul 26 22:10:24 UTC 2005


On Tue, 26 Jul 2005 08:02:12 -0700, John M. Gabriele wrote:

> It's starting to come along. :)
> 
> http://www.simisen.com/jmg/pmwiki/pmwiki.php?n=Main.JavaOnFedora

Here are a voluminous amount of suggested changes and additions!

>Sun's Java and GNU Java should be able to coexist on the same system, but
>I wouldn't know how to get that configuration working.

Sun's Java and GCJ are, of course, able to coexist on the same system. Follow
this simple five step guide to get the recommend setup:

1. Download a Sun JDK (not a JRE!) from
http://java.sun.com/j2se/1.5.0/download.jsp - and make sure you choose the
"Linux RPM in self-extracting file" option.

2. Make the file you've just downloaded executable by typing
chmod +x [insert filename here]

3. Execute it by typing ./[insert filename here] This will extract and then
install the RPM for you.

4. Download the binary package java-1.5.0-sun-compat-1.5.0.04-1jpp from
jpackage.org. (The version number may be different by the time you read this.)
You will find java-1.5.0-sun-compat near the bottom of the long
list of packages on the left side of the page - click on that and then click
on the first icon in the B column (on jpackage.org, B is for binary package,
H is for project homepage and S is for source package.)

5. Install it with rpm -ivh java-1.5.0-sun-compat-1.5.0.04-1jpp*.rpm

Optionally, you can now make the Sun JDK the default, by typing

alternatives --configure java

This will only affect "java" and a few other commands. To make the Sun Java
compiler and JDK development tools the default as well, you also need to do:

alternatives --configure javac

If you wish to use a different JDK to the default one, without changing
your current default, you will find each JDK in its own directory under
/usr/lib/jvm - along with some shortcut links like "java-gcj" to save typing.

Note that JPackage (at runtime), JPackage (when package building), and many
Java applications, all have their own separate systems for setting "default"
virtual machines. So just because you set the system default with the
alternatives command, that does not mean it will affect everything.

> Can I do Java GUI development on Fedora without Swing or AWT?
>
> Certainly. You've even probably already got the necessary packages installed. See Java-Gnome.

Certainly. You've even probably already got the necessary packages installed. The two
main options are SWT (the cross-platform toolkit that uses native libraries like GTK to render
stuff) and Java-Gnome.

If you want to develop cross-platform applications, your best choice
is probably SWT, which comes in the libswt3-gtk2 package, and is supported by Eclipse.

Eclipse has a visual editor component like other IDEs, called VE (Visual Editor), but it isn't shipped in
Fedora yet. You can download it from eclipse.org and unzip it (as root) into /usr/share/eclipse
- the eclipse updating mechanism doesn't work, so it's best to install it manually like that.
It's not necessary to install VE to develop SWT applications - VE just provides a visual, 
"drag-and-drop" way of developing SWT, Swing and AWT applications and components.

>Where do I file bugs on Java software in Fedora?
>
>There isn't a Java-software-specific bug-reporting page. Please use: https://bugzilla.redhat.com/bugzilla/ . Just be sure to search >first, to see if your bug is already listed. 

Consider carefully the appropriate bug database to use. Firstly, can you determine or estimate[1]
(for example by running the software on a Sun JDK) if it is a bug in the Java software
you are using, or it is a bug in gcj/gij/libgcj? If the former, consider if it might be
appropriate to report the bug to that project itself, rather than reporting it on the Fedora bug database.
If the latter, it is appropriate to post the bug to the fedora bugzilla (either under the specific package,
or under "gcc" if you can identify a specific compiler or interpreter bug). gcc also has its own bug database
at gcc.gnu.org, but Fedora gcc is hardly modified from mainline gcc in terms of the Java stuff, and
many of the same people read both databases, so it's not the end of the world if (improbably) you post
a Fedora-specific bug to the gcc database by mistake.

> How do I create a Java project in Eclipse on Fedora?

Easy. Just start eclipse by typing "eclipse" (that was hard, wasn't it!) (You can specify a particular virtual
machine to use by typing eclipse -vm /usr/lib/jvm/jre-gcj/bin/java .) Then go to the File menu and choose
New -> Project. Type your project name, choose the options, and click Next (for more options) or Finish.
Notice that you can import existing source code at this point.

Eclipse may now ask you whether you want to switch to the Java Perspective. If so, say Yes!

Then create a New Class. If you're starting from nothing, you probably want to ask eclipse to create a
"public static void main (String args [])" method for you at this point (Eclipse is really good at
taking of drudgery like that). Now you can go ahead are start typing!

If you develop GUIs and you prefer working in a more visual style, see above for details about Eclipse's
VE plugin.

Some quick tips: You can configure project-specific preferences (like which JDK to use, code style conventions,
warnings to supress, etc.) by right-clicking on the project in the project browser on the left and choosing
Properties. You can navigate to the declarations of fields or methods in your code by highlighting them
and pressing F2, or by using the code structure browser on the right.
When you get a compiler error, highlight the code that Eclipse is complaining about and press CTRL+1 - eclipse
will usually be able to offer you some "quick fix" suggestions as to how to fix it - and it will not only
suggest them but actually implement them for you. Very handy!

When you're comfortable with the basics of Eclipse, try right-clicking on code or variables and exploring
the many refactoring options that are on offer. Refactoring is essentially like the Quick Fix system, but
user-initiated.

Caveats: Unfortunately, a couple of things do not work well when running eclipse on libgcj on Fedora Core 4.
Firstly, some users have reported hangs with large CVS checkouts (although this may only apply to
bleeding-edge releases from the Fedora Development package repository). Secondly, debugging doesn't
work at all with a libgcj virtual machine, because it's not implemented in libgcj yet - although work on
that is underway.

> How do I use Tomcat?

Very briefly: "service tomcat4 start" or "service tomcat5 start" will start tomcat.
(Can you guess how to stop it?) Then use "rpm -ql tomcat5|less" to explore the directory structure of Tomcat
on Fedora. The main thing you need to know is that you put your webapps under /var/lib/tomcat{4,5}/webapps.

-- 
Robin

[Footnote 1] - I found a bug in AspectJ yesterday which only appeared under libgcj, but *wasn't*
a libgcj bug. It was a latent bug in AspectJ that was only exposed by a slightly different,
but still valid, collection class implementation in libgcj. So it's not logically valid to assume
that a bug that only occurs on libgcj is necessarily a bug *in* libgcj.





More information about the java-devel mailing list