December 16, 2011 These notes are ancient, and probably no longer relevant, but I have a hard time deleting anything, so here they are laying around for you to trip over. You have been warned.

Installing java from Sun -- 2009

I am running Fedora Core 11, circa July, 2009, on my AMD x86_64 machine. I go to the sun download site and fetch Java SE 6 (jdk-6u14-linux-x64.bin), which is a 78 megabyte file.

Before I go much further, I will try reading the Java tutorials on the Sun website.

The first thing among the many tutorials that catches my eye is the Hello World tutorial which quickly leads me to the Platform Installation Instructions.

I do the following:

chmod a+x jdk-6u14-linux-x64.bin
su
cd /usr/local
./jdk-6u14-linux-x64.bin
This puts all my shiny new java stuff into /usr/local/jdk1.6.0_14.

Fedora and Gnu java

There is a javac on my search path (/usr/bin/javac) which identifies itself as:

(~/JAVA) cholla $ javac
Eclipse Java Compiler 0.894_R34x, 3.4.2 release
Copyright IBM Corp 2000, 2008. All rights reserved.
(I discover this after I install the Sun java package and then just "try typing javac".)
In fact I am able to compile and run the Hello World application by:
javac HelloWorldApp.java
java HelloWorldApp

However, this compiler is NOT what I just installed from sun. When I type /usr/local/jdk1.6.0_14/bin/javac I get different messages.

It turns out /usr/bin/javac is a link to /etc/alternatives/javac which is a link to /usr/lib/jvm/java-1.5.0-gcj/bin/javac, which comes from java-1.5.0-gcj-devel-1.5.0.0-28.fc11.x86_64

Apparently this is "Gnu Java", which is a partial implementation of an older version of Java, and is quite slow compared to Sun's Java. GCJ would seem to stand for Gnu Compiler for Java. This makes no sense at all to me (having a Gnu java project that is), given that Sun's java is opensource. At least part of this is history. At one time Sun made java freely available in a way where not all components were free (you can read about this at the Gnu Java pages. My point of view at this time is that if Sun java is better, and I can download both source and executables without paying money, all I want to know is how to make the switch from Gnu to Sun java right now.

One recommendation is to add the following lines to .profile or .bashrc: #configuration for java export JAVA_HOME="/usr/local/jdk1.6.0_14" export PATH=.:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

The links in /etc/alternatives tempt me to do some quick relinking, but this is better managed via an alternatives command.

alternatives --config java
Offers choices (but only of packages installed via yum, so the latest java from sun is not available, and I will have to handle that by hand). The yum managed alternatives are:

Java and eclipse

You can go to the eclipse website and download an "Eclipse IDE for Java Developers". It is available for linux, OS-X, and Windows (and is 92 Mb). You could also download the Eclipse Classic 3.5.0 (161 Mb) which gives you Eclipse along with Java Development Tools. Another whole world to explore.

Eclipse was donated to the open source community by IBM. If nothing else, it makes programmers coming to Linux from a Windows "studio" software development environment feel comfortable. Eclipse is built out of lots of plugins, and apparently is itself implemented in java. RPM and yum managed packages provide the plugins (eclipse-jdt is the plugin for Java development tools). Eclipse has been first and foremost a tool for Windows developers and Eclipse on linux has been an awkward afterthought.

yum install eclipse-sdk
this pulls in 35 packages, including eclipse-jdt. And now typing eclipse starts "fedora eclipse" which it tells me is based on eclipse 3.4.2, and sets up to use /home/tom/workspace.

I follow a built in java tutorial, and am able to produce the Hello World example "eclipse style". But I don't think I like it: it involves making menu selections, and filling out forms to produce a template consisting of method stubs that need to be filled in. I guess this is how Windows programmers work and why Eclipse makes them feel at home.

Java graphics

Graphical applications with java are done using something called Swing. I guess it "don't mean a thing if you ain't got no Swing", or something like that. I will go with Swing until compelling reasons come along to do otherwise.

There is a whole nuther graphical environment called AWT, the Abstract Window Toolkit; as well as something called SWT. AWT is done by bindings to components native to the hosting system, whereas Swing is portable pure Java. SWT is like a new and improved AWT, and may well come as a part of the java/eclipse environment. People who advocate AWT point out that it will "look like" the host operating system, which I suppose could be important.


Notes from April of 2003

Getting java to work under linux is not too bad. It seems that you have 2 choices. You can go to java.sun.com , or you can go to blackdown.org .

I chose to go to blackdown (actually the mirror site at metalab) and download 1.4.1. I got both the j2re (20 Megabytes), and the j2sdk (40 Megabytes). I put them into /u1/java/1.4.1 on my system, used chmod to make them both executable, and ran them! They self explode into j2re1.4.1 and j2sdk1.4.1 and you are ready to rock. My last step then is to create the link:
/usr/java --> /u1/java/1.4.1/j2sdk1.4.1
After creating this link, you can put /usr/java/bin on your path and then run javac and the like.

Getting java to work as a browser plugin is a real challenge. (As an interesting contrast, I found installing the flash plugin a trivial effort). The simple way (and worth a try if you are lazy and/or frustrated), is to run a browser as root and let it install the java plugin. This may not work for certain cases (such as if you are running mozilla-1.4a). In this case, these notes may be of use to you.

One hot tip is that in the toolbar at the top of mozilla there is a help menubutton that has an entry "about plugins" that is very informative.

A web site that offers some hope in this marginally documented area of the computing landscape is: plugindoc.mozdev.org

At any rate, here is how I got the java plugin to work and lived to tell about it. First I am running Red Hat 8.0 which has a 2.4 kernel (not that it matters terribly much). What is relevant, is that this is not yet gcc 3.x, so I installed the jre and jsdk 1.4.1 that was built with gcc 2.95 as described above. Now I am running Mozilla 1.4a (which I find very nice), and it is installed in /usr/local/mozilla. Curiously enough, it wants the system default plugins in /usr/local/mozilla/plugins. NOT in /usr/local/lib/mozilla/plugins. NOT in /usr/local/lib/mozilla-1.4a/plugins. NOT in /usr/lib/mozilla/plugins. NOT in /usr/lib/mozilla-1.4/plugins.

Once I got sufficiently bored with experiments that led me to the above conclusions, I wrote the following little script:


#!/usr/bin/ruby

Jplug = "/u1/java/1.4.1/j2re1.4.1/plugin/i386/mozilla"
Pfile = "javaplugin_oji.so"
Mo1 = "/home/tom/.mozilla/plugins"
#Mo2 = "/usr/lib/mozilla-1.4a/plugins" (useles)
Mo2 = "/usr/local/mozilla/plugins"

makem = true

print "Removing links\n"
lname = Mo1 + "/" + Pfile
system ( "rm -f #{lname}" )
lname = Mo2 + "/" + Pfile
system ( "rm -f #{lname}" )

if makem
	pname = Jplug + "/" + Pfile
	print "Creating links\n"
	lname = Mo1 + "/" + Pfile
#	system ( "ln -s #{pname} #{lname}" )
	lname = Mo2 + "/" + Pfile
	system ( "ln -s #{pname} #{lname}" )
end


Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org