Mailing Lists: Apple Mailing Lists

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

Re: Class Loader Oddity???



Greg Guerin wrote:
bsd5tu1 wrote:

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

the launch will not work.
    

I find it hard to believe those are the exact Windows command-lines.
  

Those are NOT the exact command lines. The example above is just an example and not cut-n-paste. That's a typo on my part. I'm used to OS X and Linux.
Your examples show a ":" as the separator between classpath elements, but
on Windows the path-separator is ";".  As evidence, write a Java test
programs to print the "path.separator" System property, or the static value
of java.io.File.pathSeparator.

If you HAVE pasted the exact command-lines above, then I'm baffled.

Or maybe not.

The reference for the 'java' command (man page):
  <http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html>
  

Like I said, it was a typo on my part.
says this about the -jar option:
  When you use this option, the JAR file is the source of all user classes,
  and other user class path settings are ignored.
  

This I knew, and I never had any problems until we put this  on Windows.
Based on this, the -classpath arg should be ignored.  I can't speak for
Windows, but in my experience on Mac OS X, it DOES get ignored, and this
can easily be verified (see ListClassLoaders below).

So the apparent fact that it's NOT getting ignored on Windows is more
baffling than the apparent fact that ":" appears to be working as
path-separator.
  

Once again, ":" was a typo.
If I encountered this mystery on Mac OS X, I'd try this command-line:
  java -jar /full/path/to/launcher.jar
and not mess around with -classpath.  At least it's consistent with the
documentation for the -jar option.  Translating that to the correct Windows
absolute pathname is left as an exercise for the reader.


  
java -jar /full/path/to/launcher.jar is really what we use on OS X/Linux/Solaris....there are no other settings or classpaths. The new classpath stuff is a "Windows thing."
The only explanation I can think of is that your "convert pathname to URL"
procdure isn't really working correctly under Windows, so your launcher is
actually malfunctioning.  However, rather than simply failing, presetting
-classpath with an absolute pathname somehow acts as a kind of safety net
to prevent it from failing utterly.  That's just a guess, because we don't
have any launcher source code, and the launcher code seems to be at the
crux of this.

You may want to investigate what your launcher's URLClassLoaders are really
seeing with the ListClassLoaders diagnostic tool I posted a while ago
  <http://lists.apple.com/archives/java-dev/2006/May/msg00274.html>

  

This I'll do. Mr Wagner at SCSC sent me a private e-mail and said he thought the problem was  class loader related. He also said I might want to verify that the .policy files etc. related to security aren't preventing some type of loading, but he doubted it because we'd be seeing a security exception instead of "can't find the class" type of thing. He also said problems like this apparently occur with Web Start on Windows and people have to take extra precautions when loading (but why???? THAT'S what I want to know!) apps that have extra resources.
And also print the value of the "user.dir" property, since that's pivotal
for the correct interpretation of relative pathnames.

Or since the problem only occurs on Windows, maybe you should post your
question on a list or forum for Java on Windows.  Don't be surprised if
they ask to see the launcher code.


  
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.
    

You'll have to specify which "docs for classpaths" you read.
  

I'm afraid I'm not that good at writing to  convey my thoughts. The paragraph above of mine starting with "My question is..." should probably just be ignored.
Also notice: all 3 OS'es have "/" as the separator between pathname
elements, and ":" as separator between classpath elements.  Windows
doesn't.  That simple syntax difference raises the possibility of a simple
syntactical error somewhere in your launcher.

  
Possible, but unlikely. If we take our jar files and then compile the libraries directly INTO the apps, which makes the apps uneccesarily large, IMHO, they all launch and run fine on all OSes. Separate out the library though, and SMACK!!! down it goes on Windows!!
  
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?
    

Evidence against that hypothesis:
  Windows has a "current directory" and supports relative pathnames.

  -- GG

  
So did VMS, or later versions of it. However, some things STILL required a full path to identify something.


 _______________________________________________
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

  
I'll look at the Class Loader utils. It seems to me there's mounting evidence that this is the problem (Mounting evidence defined: 2 people told me!!!)  :-o
 _______________________________________________
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

References: 
 >Re: Class Loader Oddity??? (From: Greg Guerin <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.