Extension problem Mac OS X (launching of external jar doesn't work)

C

contrex

My java application use the extension mechanism (see:
http://java.sun.com/docs/books/tutorial/ext/basics/install.html) which
works very well under windows and linux. But the same app doesn't
launch under Mac OS X (Panther) throwing a
java.lang.NoSuchMethodException by the main class even when I've
copied the jar (the extension) to all three possible extension
folders which are (see:
http://developer.apple.com/document...Development/Overview/chapter_2_section_4.html):

1) /Library/Java/Extensions/
2) /System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/ext/
3) /System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Home/lib/ext/

Let me go a little bit more into the details: What I wan't is to
integrate an existing java app "SubApp" into another java app
"MainApp". Both apps are normaly standalone apps.
Thus, I just added a button to the GUI of "MainApp" which will
instanciate "SubApp" when the user clicks it. The jar of "SubApp" has
to be located therefore in the java extension folder, which is the
case.
This works fine on windows and linux but Mac OS X throws a
java.lang.NoSuchMethodException. Why?

Thanks for reading and helping!

PS: If I double-click directly the jar file of "SubApp" then this app
works fine too on Mac OS X - but standalone and not integrated in
"MainApp". What can I do (besides chuck away Mac OS X)? I don't know
much about Mac but I begin to hate it...
 
J

Jonck

In said:
My java application use the extension mechanism (see:
http://java.sun.com/docs/books/tutorial/ext/basics/install.html) which
works very well under windows and linux. But the same app doesn't
launch under Mac OS X (Panther) throwing a
java.lang.NoSuchMethodException by the main class even when I've
copied the jar (the extension) to all three possible extension
folders which are (see:
http://developer.apple.com/documentation/Java/Conceptual/
Java141Development/Overview/chapter_2_section_4.html):

1) /Library/Java/Extensions/
2) /System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/
ext/ 3) /System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/
Home/lib/ext/

Let me go a little bit more into the details: What I wan't is to
integrate an existing java app "SubApp" into another java app
"MainApp". Both apps are normaly standalone apps.
Thus, I just added a button to the GUI of "MainApp" which will
instanciate "SubApp" when the user clicks it. The jar of "SubApp" has
to be located therefore in the java extension folder, which is the
case.
This works fine on windows and linux but Mac OS X throws a
java.lang.NoSuchMethodException. Why?

Thanks for reading and helping!

PS: If I double-click directly the jar file of "SubApp" then this app
works fine too on Mac OS X - but standalone and not integrated in
"MainApp". What can I do (besides chuck away Mac OS X)? I don't know
much about Mac but I begin to hate it...

The extensions folder in OS X is (as you state as one of your options)
/Library/Java/Extensions

What you need to do is place whatever .jar file that you want to use as
an extension in this folder. For the rest nothing else is needed, this .
jar is now considered to be on your CLASSPATH.

If you are getting a NoSuchMethodException for some reason the .jar is
not found. So you should check one of the following:
1) if you are using an IDE such as Eclipse, it loads the .jar's in the
Extensions folder at startup. Therefore if you place a .jar in this
folder without restarting your IDE it is logical that the .jar will not
be found.
2) go to the terminal and type "echo $CLASSPATH". Make sure that
"Library/Java/Extensions" is in your classpath. If it does not show up,
add it.

HTH, Jonck
 
B

Batman4050

I too, have this problem on my Mac OS X computer.

What command do you use to add the $CLASSPATH?

I tried typing the following:
set CLASSPATH=.;/Library/Java/Extensions/
set $CLASSPATH=.;/Library/Java/Extensions/
env CLASSPATH=.;/Library/Java/Extensions/
env $CLASSPATH=.;/Library/Java/Extensions/

and I keep getting the error: -bash: /Library/Java/Extensions/: is a directory

The current version of Java I have is:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)
 
S

Sudsy

Batman4050 said:
I too, have this problem on my Mac OS X computer.

What command do you use to add the $CLASSPATH?

I tried typing the following:
set CLASSPATH=.;/Library/Java/Extensions/
set $CLASSPATH=.;/Library/Java/Extensions/
env CLASSPATH=.;/Library/Java/Extensions/
env $CLASSPATH=.;/Library/Java/Extensions/

and I keep getting the error: -bash: /Library/Java/Extensions/: is a directory

The current version of Java I have is:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

Under *NIX (which is what OS/X is under the covers), the semi-colon
is a command separator. You want to use a colon, e.g.

CLASSPATH=.:/Library/Java/Extensions
export CLASSPATH

Same as on the command line, e.g.

java -classpath $CLASSPATH:.:/Library/Java/Extensions <yourClass>

The semi-colon is only used as a separator on M$ systems since they
already use the colon to separate drive from path.
 
C

contrex

Thank you for your reply Jonck.
What you need to do is place whatever .jar file that you want to use as
an extension in this folder. For the rest nothing else is needed, this .
jar is now considered to be on your CLASSPATH.

This is what I thought too and it works in this manner on windows and
linux but apparently not on Mac OS X.
If you are getting a NoSuchMethodException for some reason the .jar is
not found. So you should check one of the following:

1) I don't use any IDE on Mac. I develop on windows or linux where I
make my jar files which will be then installed on Mac.

2) In csh terminal the variable CLASSPATH is undefined and in bash
terminal I get an empty line (I think it's undefined too). But who
cares, because:
A) it's just a terminal session and the variables you'll set here
don't apply to other sessions because it's just local and not system
wide. Correct me if I'm wrong - I don't know well Mac OS X.
B) This is more important: I don't want rely on any CLASSPATH
settings! This is the reason why I'm using the extension mechanism
because my "MainApp" can call "SubApp" after being copied into an
extension folder (and restart of "MainApp") without any manipulation
of CLASSAPTH settings!

The "MainApp" is able to show System Properties and I can see the
following (only the most important):
sun.boot.library.path =
/System/Library/Frameworks/JavaVM.frameworks/Versions/1.3.1/Libraries
java.class.path = MainApp.jar:/Applications/MainApp/Contents/Resources/Java/lax.jar
java.home = /System/Library/Frameworks/JavaVM.frameworks/Versions/1.3.1/Home
java.ext.dirs = /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.frameworks/Versions/1.3.1/Home/lib/ext

You see that the classpath doesn't refer any location of "SubApp". But
the "java.ext.dirs" does it do multiple times indeed!
Apparently Mac OS X doesn't care about else it would find "SubApp".

My last experience was to build an installer for "SubApp" (with
"Install Anywhere" on WinXP) in order to test a standalone
installation of "SubApp" on different plattforms. This works fine on
windows and linux but Mac OS X FAILS AGAIN.

WHAT CAN I DO?
 
S

Steve W. Jackson

:I too, have this problem on my Mac OS X computer.
:
:What command do you use to add the $CLASSPATH?
:
:I tried typing the following:
:set CLASSPATH=.;/Library/Java/Extensions/
:set $CLASSPATH=.;/Library/Java/Extensions/
:env CLASSPATH=.;/Library/Java/Extensions/
:env $CLASSPATH=.;/Library/Java/Extensions/
:
:and I keep getting the error: -bash: /Library/Java/Extensions/: is a
:directory
:
:The current version of Java I have is:
:Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141)
:Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

You need two tips here. (1) There's no reason to set a CLASSPATH
variable. (2) That's not how you set an environment variable in Bash
and most other shells.

The OP's post (which he multi-posted, BTW) included a link to an Apple
page which clearly states that jar files in /Library/Java/Extensions are
loaded by the JVM at startup, so no CLASSPATH setting is needed.

Setting an environment variable in Bash (and other shells which trace
their roots to the Bourne shell) is done as follows:

VARIABLE=value
export VARIABLE

Or the alternative in Bash and some others is "export VARIABLE=value".

= Steve =
 
J

Jonck

The "MainApp" is able to show System Properties and I can see the
following (only the most important):
sun.boot.library.path =
/System/Library/Frameworks/JavaVM.frameworks/Versions/1.3.1/Libraries
java.class.path = MainApp.jar:/Applications/MainApp/Contents/Resources/
Java/lax.jar java.home = /System/Library/Frameworks/JavaVM.frameworks/
Versions/1.3.1/Home java.ext.dirs = /Library/Java/Extensions:/System/
Library/Java/Extensions:/System/Library/Frameworks/JavaVM.frameworks/
Versions/1.3.1/Home/lib/ext

Ok, since you are getting a NoSuchMethodException could it be that the
method that is causing this exception is implemented only in Java
versions >1.3.1? Which version of Java are you using on your M$ and
Linux machines?
 
C

contrex

Ok, since you are getting a NoSuchMethodException could it be that the
method that is causing this exception is implemented only in Java
versions >1.3.1? Which version of Java are you using on your M$ and
Linux machines?

Yes, yes and yes, that's it!!!
"Install Anywhere" has an option (only for Mac OS) which defines the JVM
the application shall use. And this one was set to 1.3.1. That's the
reason why I wasn't asked while installation on Mac OS which JVM I want
to use because the Installer already knew it. This is different on
Windows and Linux: the end-user has to choose a JVM from a list during
installation process. And when I choose a JVM < 1.4 it doesn't work
neither!

Thus I made a new installer for Mac OS with option 1.4.*
I installed it and it works like a charm!
Thanks Jonck for this great hint!
 
S

steve

I too, have this problem on my Mac OS X computer.

What command do you use to add the $CLASSPATH?

I tried typing the following:
set CLASSPATH=.;/Library/Java/Extensions/
set $CLASSPATH=.;/Library/Java/Extensions/
env CLASSPATH=.;/Library/Java/Extensions/
env $CLASSPATH=.;/Library/Java/Extensions/

and I keep getting the error: -bash: /Library/Java/Extensions/: is a
directory

The current version of Java I have is:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-141)
Java HotSpot(TM) Client VM (build 1.4.2-38, mixed mode)

you are resetting you class path!!!
you need to keep all the other stuff & add to the existing classpath.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top