how to run tools from a java archive (jar file)

I used to run Multivalent from http://multivalent.sourceforge.net/ but am now getting error messages like this:
Exception in thread "main" java.lang.NoClassDefFoundError: tools/pdf/Impose

This happens even when I'm in the directory containing the jar file.

I've never installed it by myself though so am not sure that I've done it right. I put the jar file into ~/library/java but that was a guess after reading lots of web pages that don't quite say what to do. They assume that I've read some intro material that I haven't been able to find.

Any pointers on where I can find out how to do this right?

In case it's relevant, java -version returns:

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

and echo $CLASSPATH returns a blank line.

MacBook Pro, Mac OS X (10.5.5), 2.2 GHz, 2 MB

Posted on Nov 16, 2008 8:03 PM

Reply
9 replies

Nov 17, 2008 8:42 PM in response to Bob Lang1

Thanks, but I was after the command-line tools, not the browser. I can also get the browser by double-clicking on the icon but there's something stopping the command-line tools from working.

For example, to compress bigfile.pdf, you use the command,
*java tool.pdf.Compress bigfile.pdf*
and it does things like re-code LZW into Flate.

The tools are incredibly useful.

I thought that I all needed to do was put the file into ~/library/java.

Does this work on your system too? Or does it work if you're in your desktop directory where you downloaded the Multivalent jarfile?

Message was edited by: wyvern-eater

Nov 18, 2008 7:31 AM in response to wyvern-eater

wyvern-eater wrote:
True, but then I'd need a copy of Multivalent in every directory where I work with pdf files, or to move those pdf files into the multivalent directory.


Not necessarily. The -cp parameter can include a complete file spec. You can create a Unix alias for the whole command line. For example:

alias compress='java -cp ~/JarFolder/Multivalent20060102.jar tool.pdf.Compress'

(Assuming that the jar file is in the folder JarFolder

Now, all you have to type is "compress filename" (without quotes) and the java program runs.

It's much easier with the classpath, and to strip the version identifier off the filename to make updates easier.


On Macs, the default classpath includes the folder /Library/Java/Extensions. If you drop the jar file into this folder then you won't need to specify an explicit CLASSPATH variable nor the -cp option.

Hope this helps

Bob

Nov 18, 2008 11:17 AM in response to Bob Lang1

Not necessarily. The -cp parameter can include a complete file spec. You can create a Unix alias for the whole command line. For example:

alias compress='java -cp ~/JarFolder/Multivalent20060102.jar tool.pdf.Compress'


I use Multivalent tools a lot for maybe a week at a time, then don't touch them for a couple of months. During the downtime I'd just forget aliases like this.

On Macs, the default classpath includes the folder /Library/Java/Extensions. If you drop the jar file into this folder then you won't need to specify an explicit CLASSPATH variable nor the -cp option.


I thought so too, but it doesn't appear to be the case on my computer. Both /Library/java/extensions and ~/library/java are on DefaultClasspath but CLASSPATH is empty. And even when the directories are specified, the jar file in it is ignored unless I specify that explicitly as well. I do not remember needing to do that in the past. It used to just work when it was in a classpath directory.

I get the impression that something has changed in how Mac Java handles the classpath. In searching for answers I noticed that many people were attributing their difficulties to a classpath change in a recent update. It is not something that I see myself dealing with in the near future. But it would be helpful to know of a primer for newcomers to Java and the OS X directory conventions so they know where to put things and what paths to set for basics like this.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to run tools from a java archive (jar file)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.