PDA

View Full Version : Java Upgrade Hell



Arkaein
03-23-2004, 05:23 AM
After recently installing Knoppix on my new computer, I decided to start working on a programming project in Java started on my previous computer. I discovered that some of the code was not compiling correctly, possibly related to javac being gcj on my new system as opposed to the Sun java compiler on my old system. Anyway, I decided to try installing some new java tools.

Not really sure what I needed, I installed Synaptic to help my search. So far so good. I see the Jikes compiler, try it, don't get it to work, no biggie, move onto Eclipse. Here is where things get hairy. I try to install the complete Eclipse development kit/platform, whatever, about 6 pacakges in total. Something breaks along the way, although eclipse seems partially installed. I can run it sometimes, though it crashes easily and most times cannot start at all. I decide to say screw it and just uninstall both Jikes and all the Eclipse stuff.

I think I got some more apt-get errors on uninstall, though I can't remember for sure. My Java VM still seems to run okay, although now it gives the error:

Mar 22, 2004 11:11:16 PM java.util.prefs.FileSystemPreferences$3 run
WARNING: Could not create system preferences directory. System preferences are unusable.

when I run something, which it did not before. I would like to know what is happening here and how I can clean it up.

The biggest problem though is that Mozilla no longer recognizes the Java plugin! Everything looks correct, although the symlinks seem a bit convoluted they all point to the correct places: /usr/lib/mozilla/plugins/javaplugin_oji.so --> /etc/alternatives/javaplugin_oji.so --> /usr/lib/j2se/1.4/jre/i386/mozilla/javaplugin_oji.so. In that final target the mozilla directory is itself a symlink to same level directory ns610-gcc32. Everything appears to be just as it should but mozilla shows no java plugin under About -> Plugins, and tells me I need to install a plugin when I try to run applets. This is after multiple Mozilla restarts and a system reboot.

Getting my Java VM and plugin back in working order is my top priority. After that, and advice related to getting a solid, Java 1.4 development environment setup would be greatly appreciated. Currently I have gcj-3.3 as my java compiler and j2re1.4 (Blackdown 1.4.0.99beta-1) as VM. Both of these were included in the original Knoppix install and AFAIK have not been modified but the other installations I've tried.

Thanks.

Arkaein
03-23-2004, 05:29 AM
Just discovered that Java works fine in Konqueror, so my problem isn't quite as "tragic" as I thought it might be, although Mozilla is still my preferred browser and I'd really liek to get everything at least back to working as well as it did before, and prefereably better as far as Java development.

c123
03-23-2004, 09:35 AM
To get rid of

Mar 22, 2004 11:11:16 PM java.util.prefs.FileSystemPreferences$3 run
WARNING: Could not create system preferences directory. System preferences are unusable.

run *any* java app as *root* once; this creates the 'system preference directory'. You should then no longer see this message (regradless of whether you're runnign a java app as root or as a normal user).

Installing a jvm (or is it jre?) is a real pita. I've installed the same java version as you (via apt-get) and whenever I install any other package I still get a message that j2re1.4 is not correctly installed. Really should file a bug :( I don't know how to fix this, and I doubt I've got java support for Firefox (my preferred browser), haven't checked Konqueror yet.

I'm so annoyed with the j2re1.4 package that I'm considering uninstalling it and trying another jvm (kaffe perhaps).

HTH

jam123
03-23-2004, 06:06 PM
I took the following steps after downloading the Sun's Linux JVM.
It would be nice if Sun would release Java as a DEB package
and would allow the debian mirrors to list it in the non-free (as in non-open source) section, but this script wasn't so bad.

After installing this way, I didn't have any problem installing/using eclipse.



su - root
chmod u+x ./j2sdk-1_4_2_03-linux-i586.bin

mkdir /usr/java/
cd /usr/java/
/root/j2sdk-1_4_2_03-linux-i586.bin

update-alternatives --install /usr/bin/java java \ /usr/java/j2sdk1.4.2_03/bin/java 350

update-alternatives --install /usr/bin/javac javac \
/usr/java/j2sdk1.4.2_03/bin/javac 350

update-alternatives --install /usr/bin/javah javah \
/usr/java/j2sdk1.4.2_03/bin/javah 350

Arkaein
03-23-2004, 11:41 PM
First thanks to c123 for telling me how to get rid of that annoying system prefs message. I have a feeling I might have dealt with that sometime in the past, but forgotten about it.

Jam123, your advice sounds good too. I had thought about just installing the Sun VM since I've used it successfully before, and because there is a stable version of 1.4 available compared to the 1.4 beta of Blackdown, but was leary of installing non-Debian packages on my system which might cause conflicts. After looking up the update-alternatives command, the debian way of supporting interchangeable modules makes more sense to me now, and I plan on probably taking this route.

However, I would like to get my Mozilla plugin issue figured out, even though I will probably need to repeat the steps once I install the Sun JVM. I've made a little headway towards figuring things out. I noticed that my Mozilla plugins directory had a link to javaplugin_oji.so but NOT to libjavaplugin_oji.so, as is recommended on Mozilla's webpage. I added the link, and now about:plugins correctly identifies the plugin, but Mozilla freezes when I try to load a Java applet. I tried removing the seemingly unnecessary link to javaplugin_oji.so, but this makes no difference. Clearly something is happening, but not correctly.

Any ideas?

Stephen
03-24-2004, 12:32 AM
However, I would like to get my Mozilla plugin issue figured out, even though I will probably need to repeat the steps once I install the Sun JVM. I've made a little headway towards figuring things out. I noticed that my Mozilla plugins directory had a link to javaplugin_oji.so but NOT to libjavaplugin_oji.so, as is recommended on Mozilla's webpage. I added the link, and now about:plugins correctly identifies the plugin, but Mozilla freezes when I try to load a Java applet. I tried removing the seemingly unnecessary link to javaplugin_oji.so, but this makes no difference. Clearly something is happening, but not correctly.

Any ideas?

You may want to go to http://lists.debian.org and search the Debian User mailing list this topic comes up there all the time there is something about getting the right version with the proper complier used involved with the problem IIRC.

Arkaein
03-24-2004, 01:14 AM
Well, if my problem is that my Blackdown JVM somehow got switched out with one compiled using an incompatible version of gcc, which I believe would explains why it works by itself but not with Mozilla, will the Sun JVM work correctly with Mozilla? I'm probably going to install it anyway, but I thought I read that at least a while ago Sun's JVMs were being compiled with a version of gcc incompatible with newer builds of Mozilla, is this still the case?

Also, for the method of installing Java jam123 suggested, should I uninstall my current JVM first, and if not, do I need to explicitly set which JVM is used by default through other update-alternatives commands (and do those backslashes in the commands do anything, or just supress linefeeds)?

Thanks.

Jatronn
03-25-2004, 06:07 PM
Hello Arkaein,

like jam123 i would suggest to take the Java SDK from SUN's website directly and not use Debians' not that cool Java stuff.

First i would remove all of Debian's Java things (gcj) and then download and install SUN's Java ( http://java.sun.com/j2se/1.4.2/download.html ). Create some symlinks for some bin/ directory (e.g.: /usr/local/bin) to your Java binaries (java, javac, javaw, javadoc, ...).
Install Eclipse (2.1 found the Java installation on my system) and
be happy :)

For your Mozilla problem: Which version do you use? Could it be that the Java plugin that is compiled with gcc3.2 is not the right thing for you? Java and Mozilla have to be compiled with the same gcc version, i think.

That was all I've done and I am very comfortable with it.

Hopefully my proposals will help you

garyng
03-25-2004, 06:18 PM
I just don't understand why a compiler matters. This IMO is completely unacceptable and hard to convey message to an average user.

Arkaein
03-26-2004, 02:25 AM
Thanks for the advice Jatronn, whether to uninstall stuff first was my bigget issue, although I think I will leave gcj and just make sure it is NOT linked to from /usr/bin/java. I may want to compile native binaries at some point, and the gcc set of tools are sufficiently separated from the Java runtime environment that these ought to be able to co-exist all right.

The plugin issue is strange, because like I mentioned above everything did work when I initially installed Knoppix. Mozilla 1.5, with libjavaplugin_oji.so in the mozilla/plugins directory linked to the actual file in the ns610-gcc32 directory (with the link in /etc/alternatives in the middle). This jives with everything I've read, including the documentation on mozdev.org. Oh well, I've already removed the link from Mozilla to prevent accidental crashes, so I'll just have to try out the new JVM when I get it installed.

BTW, I think I'll go with the Sun Java VM, since I've installed it before on previous systems, but has anyone compare the IBM JVM with the Sun one? I've read that the IBM VM may give better perfomance on average, and I might like to try it out.

Arkaein
03-26-2004, 04:04 AM
Update: I just uninstalled my existing JRE using Synaptic, and installed IBM's Java SDK (simply done by extracting a tarball to /opt, and adding the JRE bin path to my bash PATH variable), and setting it up for Debian according to the instructions given by jam123. I went with IBM's SDK because I just wanted to give it a try, and becuase I thought it would be ideal for running Eclipse, and after a little research it seemed it could do everything for me that Sun's SDK would do.

Anyway, I was able to get the Java plugin working just fine in Mozilla, which was goal #1, but now normal java execution and compiling doesn't work! I get the error

JVM not found: libjvm.so - libjvm.so

Whenever I try to execute a Java program or compile Java code. libjvm.so is located in /opt/IBMJava2-141/jre/bin/classic/ for my system. I tried making a symlink to it from /usr/bin/, just to see what would happen but there was no difference.

The fact that applets run perfectly (at least in Mozilla, they've STOPPED woking in Konqueror because it apparently uses the installed Java VM directly with no need for a plugin) tells me that I must be close to a working Java environment, and that I just need something to help it find libjvm.so. I've tried adding additional paths to my PATH variable, but nothing is helping.

Someone please tell me how to fix this.

Arkaein
03-26-2004, 04:38 AM
never mind the previous post, I found a page at http://www-106.ibm.com/developerworks/forums/dw_thread.jsp?forum=190&thread=6316&cat=10 that indicates that for some reason IBM's JVM does not work right if it is called through more than one symlink. Because my current setup has /usr/bin/java -> /etc/alternatives/java -> /opt/IMBJava2-141/bin/java it fails if I type java, while it works if I use the direct path or the /etc symlink.

This leads me to a different question: I wanted to see what would happen if I try to install Eclipse though Synaptic, and it wants to install j2re as a dependency. This does not change even after I install the java-virtual-machine-dummy package.

Is there a SAFE way I can install eclipse using apt-get/Synaptic? And although it wouldn't be my first choice, if I don't mind having two JVMs on my system, if I just let it install the Blackdown JVM to fill the dependency and change my symlinks back afterwards, will there be any ill effects on my system? Right now that seems like it might be the simplest solution, and should prevent apt-get yammering about Java related dependencies in the future, I would think.

Arkaein
03-30-2004, 03:00 AM
Here's a final update, for any who may be interested.

I just installed Eclipse. Synaptic gave me some errors, but none seem related to the specific Eclipse package(s), but rather related packages. Eclipse itself seems to be running like a champ on top of the IBM JVM.

I did have to install the Blackdown JVM to fulfill the Eclipse dependencies, so I had to manually relink /usr/bin/java to the IBM JVM, and remove the mozilla plugin link to the Blackdown Java applet plugin. Plugins work correctly in both Moz and Konq.

I imagine that in the future upgrades to Java or related apps may require again fixing these links manually, but for now everything seems to be working smoothly.