Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Class Loader Oddity???



Consider the following:

We have 3 apps in jar format we'll call aaa.jar, bbb.jar, and ccc.jar and all of these use a library IN THE SAME DIRECTORY we'll call abc.jar.

aaa, bbb, ccc all have main methods and manifest similar to this:

Main-Class: aaa
Class-Path: abc.jar

If we go to this directory and then type

java -jar aaa.jar

or

java -jar bbb.jar

or

java -jar ccc.jar

each respective app will run, using methods from the library as needed. We test this on all platforms, which for us is OS X, Linux, Solaris, and Windows XP and it always runs just fine.

Now we have an app that is going to load these same applications via a URL class loader and then launch them (after converthing their names to URLs etc etc etc)

Here's the oddity:

On Solaris, Linux, and OS X, this works fine. The ULRClassLoader loads these apps and runs them fine, but on Windows XP we MUST supply a full classpath to the "launcher."

For example, let's say our launcher and the aaa ... ccc and libraries are all in a directory called /Users/test/runner.

If we switch to this directory and type "java -jar launcher..jar" on OS X, Linux, and and Solaris, the launcher app will run and correspondingly launch aaa through ccc as needed.

Now if we do the same on Windoze, it throws an exception when the launcher tries to load one of the apps requiring the library abc.jar. To circumvent (correct) this, we must launch the app on Windows with a full path passed to the launcher with the library's name in it like this:

java -classpath .:C:\Users\test\runner\abc.jar -jar launcher.jar

Now the launcher will go ahead and successfully launch aaa, bbb, and ccc. Note that if we try and take a short cut, like

java -classpath .:.\abc.jar -jar launcher.jar

the launch will not work.

My question is whether we've stumbled on some type of a fluke or not. If you read the docs for classpaths, it implies to me that the FULL classpath setting (like the way it's done in Windows) is the correct way, and yet 3 OSes (OS X, Linux, Solaris) seem to be able to reference the jarred library with respect to their own jar files.

A long time ago I did some work on VMS systems (the Father of Windoze) and I seem to remember at the time the same sort of absolute referencing of names, and I also remember way back then how dumb I thought it was that the operating system couldn't handle relative references. Is this what we're seeing here?

Thanks as Usual!!

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.