• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Virtual Machines on Linux  RSS feed

 
Ra Carter
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

I installed most applications on my linux laptop with my distros standard package manager (apt-get in this case) and repositories and for java applications it installs the gnu java vm (/usr/lib/jvm/java-gcj).

I am looking to control what Java VM (and Java libraries) are used by my applications, namely I want to use the Sun Java VM right now, but I don't want to remove the what's already there.

To accomplish this I decided to put my sun java installation at the top of my $PATH and I think that works but I'm not sure about java libraries... do I have to modify another variable for java applications like azureus to choose the sun libraries first before looking elsewhere?

Also is there a better way to do all of this? Are there any standard linux utilities that helps switch VMs on the fly? I though someone told me red hat did something like this but I am not sure.

Finally is there any reason I should be afraid of the gcj/gnu java utilities. Why are they even needed and why can't sun's vm be distributed normally? How much if any of Sun's Java is open source?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aa) A system-variable JAVA_HOME=/opt/sun-java is sufficient often.
Depending on the question if only one user or all need access to java, you would set it system- or user-wide.
aa1) In ubuntu, which is a debian-based distro, /etc/environment would be the place to do it, /etc/profile, or /etc/bashrc if 'environment' isn't available.
aa2) Depending on your shell - probably bash, ~/.bash_login and ~/.bashrc might be used.

ab) To enable java in the browser, a symbolic link to the lib...plugin.so - file might be neccessary.

ac) Ubuntu (and perhaps more Debian-based distros) uses a somehow confusing mechanism, called 'alternatives'; I would call this a call-back-design.
Use man update-alternatives or ask if /etc/alternatives is present.

b) I don't use azureus so I may only guess.
Setting 'JAVA_HOME' and organising things, so sun's java is found first, should be enough.

c) See ac). If alternatives aren't present, a script could help, in conjunction with symbolic links.
You don't like to change the JAVA_HOME - variable, because running shells won't get a change, which was made elsewhere.
I use this script to change between java-1.5 and java-1.6 on the fly - a similar problem:

JAVA_HOME allways points to /opt/java.
/opt/java is a symbolic link to /home/stefan/lib/java.
Stefan (that's me) isn't allowed to create symbolic links in /opt, so there is an additional level of indirection.
/home/stefan/lib/java links back direction /opt, either to /opt/jdk-1.5 or /opt/jdk-1.6, where the files really are.
The PATH includes $JAVA_HOME/bin/, which is either /opt/jdk-1.6/bin or /opt/jdk-1.5/bin.
A bit complicated, but works.

The update-alternatives - way is similar, but I had my solution before.

d) If you are afraid, your program will not run, because it's using recent language-features, yes.
Afaik, gcj is somewhere between 1.3 and 1.4 compared to suns java.
Perhaps enough for most Applets, but not appropriate for developers, since you don't like to push the gcj-project forward yourself.

GCJ is needed, because it's truely open source, and may be shipped according to the GNU - and most distros license.
This way many users may use applets, without downloading SUNs Java before.
And the work of the GCJ-project is honored.

You get the JDK from SUN for free, including the JRE.
You may distribute the JRE without payment, but afaik not the JDK.
The source of the classes is part of the JDK, so you might step into the source with your debugger.
But you're not allowed to change these sources to your needs (and ship them as Java++ or something).

The JVM itself isn't available as source.
The FOSS-community is asking SUN for years to make it free, and SUN always refused to do so.

Seeing different Smalltalk-dialects and libraries out there, perhaps this wasn't a bad decision.

But some weeks ago I read about new rumours, that SUN is thinking about making Java FOSS stepwise - I don't know how valid that is.

Perhaps Java today is in a position strong enough to keep in a main line, when it becomes Open Source.
But I'm neither following the FOSS-debate related to Java very concentrated, nor good informed about the history of smalltalk, to judge - this is more a wild speculation from far away.

[ July 26, 2006: Message edited by: Stefan Wagner ]
[ July 26, 2006: Message edited by: Stefan Wagner ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!