Home Wiki > openSUSE:Java jpackage-utils
Sign up | Login

openSUSE:Java jpackage-utils

tagline: From openSUSE

The project jpackage.org brings the set of the common rules, rpm macros and a scripts, which are be usefull (not only) for the package maintainers.


build-classpath - Small utility to build a Java CLASSPATH with the named JARs. The CLASSPATH is returned to standard output. This script should be used in a %pre, %build section of spec file, or in the pre/post un/install scriplets, or in the wrapper scripts.

The commons forms of usage are:

Setup of the CLASSPATH

$ build-classpath ant
$ export CLASSPATH=$(build-classpath ant servletapi5)
$ echo ${CLASSPATH}

When the jar is located in a subdirectory of a %{_javadir}, you'll need to write

$ build-classpath asm/asm

If you need all of the classes in a subdirectory, you should simply write

$ build-classpath asm/

Note, that build-classpath will return the same output if there's some typo in the aruments, so the output of the build-classpath asm/foo will be the same as the example above!

It's also possible to use the build-classpath to create symbolic links, if the program expects the jars in some external directory.

$ ln -s $(build-classpath ant)
$ readlink ant.jar
$ ln -s $(build-classpath ant) libs/expected_jar_name-1.0.9.jar
$ readlink libs/expected_jar_name-1.0.9.jar

The combination of build-classpath and ln should produces a bad symlinks in cases, when the build-classpath returns a multiple paths.


Small script to build a classpath from a directory. This script find all the jar files in specified directory(ies) and produce a CLASSPATH.

build-classpath-directory /usr/share/java


Build a JAR repository in the named directory by copying files or creating symbolic links. This script is better solution how to produre a symlinks (or a copy of the jar file), than the combination of the build-classpath and a ln (or cp).

If no option is specified the default action will be to create symbolic links. In other cases, the script has a following arguments:

  • -c, --copy copy files instead linking
  • -h, --hard create hard links
  • -p, --preserve-naming preserve the names of the original JAR files
  • -s, --soft, --symbolic create symbolic links (default)

The common usage is simple

$ mkdir libs
$ build-jar-repository libs ant asm/asm

The build-jar-repository<code> do not produce symlinks like <code>build-classpath, but add a brackets to the name of the file.

$ ls libs
[ant].jar  [asm][asm].jar

The purpose of brackets is to identify the symlinks created by script and is possible to re-run the script on the directory and link them to the new location. This behavior should be supressed by the -p, --preserve-naming argument.

$ build-jar-repository -p libs ant asm/asm
ant.jar asm_asm.jar

In this case, the slash symbol was replaced by underscores and a default action was changed to the copy, so if you'd like to have a symlink of the jars, you've to add a -s argument.