I need to create a class that will hava a method to gather email addresses from a remote data source. I can accomplish this in WDSC for use in my web apps. However, I need this class so I can put it in a jar file that can be used from a remote call on our iSeries server.
I have created a simple java class(just to get started and learn) and compiled it. However, when I try to call it from a command line I get NoClassDefFoundError.
Caused by: java.lang.ClassNotFoundException: Emailaddresses.mean() at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
The package name is part of your class name, so if you have package demo; at the top of your file your class name is actually demo.Emailaddresses, so your command line should be java demo.Emailaddresses
Joined: Nov 16, 2004
Originally posted by Joanne Neal: The package name is part of your class name, so if you have package demo; at the top of your file your class name is actually demo.Emailaddresses, so your command line should be java demo.Emailaddresses
Still returns a NoClassDefFoundError for some reason. Any other suggestions? I really thank eveyone for the help.
Joined: Oct 13, 2005
Please explain exactly how you are compiling your class, and which folder you are invoking it from.
You should always invoke demo.Foo from one folder "up" from demo, and you call it by saying
There are several ways to compile Foo; let us imagine that demo is an immediate subfolder of "java_apps".
1: Create a folder called demo inside java_apps.
Put the Foo.java file inside demo. Navigate to demo, call "javac Foo.java".
2: Create a folder called demo inside java_apps.
Put Foo.java inside java_apps. Navigate to java_apps. Call "javac demo/Foo.java".
3: No need to create the demo folder.
Put Foo.java inside java_apps and navigate to java_apps. Compile with "javac -d . Foo.java". The -d bit will create any folders necessary and the . bit means look for files in current directory.
I am sure there are other ways to compile classes. You may need to compile several simultaneously with
"javac ... Foo.java Bar.java" or similar. [ September 11, 2008: Message edited by: Campbell Ritchie ]
Joined: Nov 16, 2004
That worked. Thanks.
My next step is to import the jt400.jar.
I have it in my demo folder. Added the following to my class.
At this point it compiles ok.
However, when I add a line of code in the main method like:
AS400JDBCDataSource datasource = new AS400JDBCDataSource("gvas400");
to access the methods of jt400.jar it fails to compile.
C:\WDSC\sdk\bin>javac c:\demo\Emailaddresses.java c:\demo\Emailaddresses.java:0: Class javax.sql.DataSource not found in class com .ibm.as400.access.AS400JDBCDataSource. package demo; ^