imported classes

Hello there!
I have encountered a problem while trying to use classes from a third party imported package. I have, as expected, tried to use different settings for my CLASSPATH, but to no avail. And to make things worse, same thing happens on two platforms: Win 98 and Win NT. I have written an applet using classes from com.ibm.mq.jar (a transaction processing middleware). The location of the jar file is stated in my CLASSPATH and the package is imported in the first line of my code.
The class compiles all right.
I then call the applet from a small html file.
When running 'appletviewer <myhtml>' I always get
'NoClassDefFoundError <class name>', where class name is the name of the first class from the imported package. However, if I do
'appletviewer -debug <class name>', followed by 'run', eveything runs OK. The problem is consistent across two platforms (98 & NT).
I am using JDK 1.2.2 from Sun and the complete name of the third party package is IBM's MQ Series Client for Java.
As I am quite new to Java and not very skilled on Win, my investigations hit the wall. I would really appreciate your help. Should you need further details, please email me.

TIA

George Topfner

George Topfner
topfner@computer.org
61 412 260 455
[1365 byte] By [topfner] at [2007-11-15 20:12:34]
# 1 Re: imported classes
Is it the case that your JVM running the applet can not reference the third-party package that you
want to use. JVM do not support these packages even if you set the classpath. You may try to modify
your code to run in as the Java application. And you may observe if it runs or not. If it works fine,
It should be the case the package that you set can not be referenced; if it does not work fine, your
classpath is not set properly, hence, even the application can not be run correctly. I never try MQ
production. This is for suggestion.
good luck,
Alfred Wu
kib63613 at 2007-11-10 2:53:38 >
# 2 Re: imported classes
George,

The problem you're having is an age-old problem when it comes to Java.

The quickest fix I know of is to place the JAR file in the same directory as the class files that call it.

Regards,
dogBear
dogbear at 2007-11-10 2:54:38 >
# 3 Re: imported classes
just add the jar file in the applet tag's archive param.

<APPLET ..... ARCHIVE=xxx.jar></APPLET>

And remember on thing , Browsers wont look the local machine's CLASSPATH variable.
( I am not sure about AppletViewer ).

Poochi..
poochi at 2007-11-10 2:55:37 >
# 4 Re: imported classes
First of all thank you all for your answers! That was a refreshing change from the total lack of interest at Sun's forum.
I have tried all your hints and suggestions, but so far no result. And I found something even more strange (at least to me):
if 'appletviewer <myapplet>', I get NoClassDefFoundError (same imported class)
if 'java sun.applet.AppletViewer <myapplet>', everything goes all right.
So, summing up, 'appletviewer -debug <myapplet>' works, 'java sun.applet.AppletViewer <myapplet>' works, but 'appletviewer <myapplet> never worked, on two platforms, NT and 98.

George Topfner
topfner@computer.org
61 412 260 455
topfner at 2007-11-10 2:56:42 >
# 5 Re: imported classes
O.K Try this..

1. Create a Directroy called "MyProject" under "C:\" ( c:\myproject )
2. Copy your applet class under this directory.( xxx.class )
3. copy your jar file under this directory. ( yyy.jar )
4. Create a HTML file something like the following and store it under c:\myproject

<HTML>
<APPLET CODE=xxx.class WIDTH = 400 HEIGHT = 400 ARCHIVE=yyy.jar ></APPLET>
</HTML>
5. Now , try to run this HTML file.

6. If you still get the error , Unjar your yyy.jar file under c:\myproject directory

Command : c:\myproject:> jar -xvf yyy.jar

7. Check whether all the required classes are there or not.
8. If they are , now try to run the applet.

Good luck , and dont forget to tell me the result :-)

Poochi..
poochi at 2007-11-10 2:57:46 >
# 6 Re: imported classes
Poochi, you are a champion man! Finally, it worked, just as you suggested in your last point from your last post.
I moved my jar file (com.ibm.mq.jar) to my working directory, I unjared it as you suggested and I ended up with a direcory structure com/ibm/mq/<names.class>, containing the classes previously flagged as NoClassDefFound Error. Everything was there, as it was supposed to. Then I simply run 'appletviewer <myhtml> and BINGO, all worked just fine. I still don't know why it doesn't work in jar format, but at least I have a workaround now. In the next few days I will try the same thing on a Unix box, maybe I'll have more luck than on Win. After all, my MQ server lives on a Unix box! Just incidentally, prior to my Java endevours I have developed many other MQ client applications in C/C++ on both Unix and Win and never had problems. Once again, thank you!

George Topfner
topfner@computer.org
61 412 260 455
topfner at 2007-11-10 2:58:48 >
# 7 Re: imported classes
You are welcome topfner. Nice to know that i have helped someone.. :-)
poochi at 2007-11-10 2:59:41 >
# 8 Re: imported classes
Hi,
I am trying to write an application and am having the same problem as the person who started this thread. It is not finding all the classes in the com.ibm.mq package. I followed the instructions of unjarring the file. Do you think I should delete the jar file from \jdk1.2.2\jre\lib\ext? What else can I try?

Thanks.
Jim
jhomme at 2007-11-10 3:00:44 >
# 9 Re: imported classes
Yes, indeed, finally some progress!!! This worked for me as well, but having one other problem...getting:
java.security.AccessControlException: access denied (java.io.FilePermission images/mnt.gif read)
obviously on my images, resides in same directory...can you explain what causes this or what must be done to load my images? Thanks!
daileyps at 2007-11-10 3:01:53 >