I have been using java for a while now but not using the package statement. (Gasp) I know. Well I am trying to purge myself of this nasty habit but any program that imports something from a non-system jar (ie xercies,jt400) etc. gives me a java.lang.NoClassDefFoundError: at runtime. If I take out the package statement and run it, all is well. Without any changes to the classpath. Any thoughts. This is on an AS400 or ISeries or whatever the marketers have come up with lately.
You need to include those jar files on your runtime classpath, of course, but you also need to build the jars properly. Java will look for a class foo.bar.ClassName in a file named ClassName.class in a directory "bar" in a directory "foo" -- i.e., it will look for foo/bar/ClassName.class. You need to build your jars this way -- i.e., don't just put ClassName.class into the jar, but the "foo" and "bar" directories, too.
The jar files I am including are built (presumably) by people who know what their doing (ie not like me) for example jt400.jar is written by the JTOPEN project. So I do not think this is it.
Someone else suggested that I had to compile it the same way as I will run it. So for example if the package name is companyname.utils then I would need to be in the parent directory of companyname and use javac companyname.utils.Test and then run it using java companyname.utils.Test
normally I would make /companyname/utils/ my current directory and then do a javac Test.java to compile, but run it from / using java companyname.utils.Test This does work but only if I do not access any object from the jt400.jar
Again if I use the default package and run it from the utils directory everything works fine.
Since no one appears to be jumping at the bit here as to what might be going on here perhaps someone could give me some advise as to what to try next? Are there any AS/400-Iseries gurus out there? It looks like this might be a platform dependent problem. Any help would be appreciated. Thanks.