[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Solution for CLASSPATH



Hi all,
I figured a way to make the job of java packaging a bit easier. The
current approach is to create wrapper scripts that define the classpath
and call java with the name of class containing the main.

The problem is with package A depending on libraries from package B
which in turns depends on libraries from package C. Package A needs to
be aware of that and include both in the classpath.

My solution is to have a custom classloader that is aware of
/usr/share/java and with the possibilty of additional repositories. So
as long as everything is under /usr/share/java all java packages can
find all classes without the need for symlinks and explicit listing of
jars in the CLASSPATH.
So to create a wrapper for a java package you would only need to have a
script that calls

I have created the classloader (extends java.net.URLClassLoader) and it
works ok. deb-java is the wrapper script for the classloader. It sets
the classpath only for the jar file with the classloader and does:

java -Djava.system.class.loader=DebianClassLoader $@


Examples: 
CLASSPATH is not set.

ant can be invoked with:
deb-java org.apache.tools.ant.Main

argouml can be invoked with deb-java org.argouml.application.Main

Package with the classloader and the sources are at:
http://anarxia.dyndns.org:2180/debian/pool/


What do you think?

Nicos



Reply to: