Hi,
I know there are plenty of questions regarding this error, but I haven't found it easy to find one exactly like mine.
Here goes.
I have a pretty small application that writes DB data to a csv file and then uploads it to a server. I have it running on my local box out of eclipse which is great, but the final version needs to be run as a cron job on a server box from command line.
I'm working on the command line call for the main java class and its giving me lots of trouble.
My dependency structure is as such: My classes
- package=gtechReconcile
- classes= GtechReconciler.java, CSVFile.java, QueryMachine.java, FTPSender.java
My external libs
- ojdbc14.zip
- edtftpj.jar
I run the following line in the terminal in the directory above the compile source package (ie /path/to/classes where /path/to/classes/gtechReconcile/ has all the compiled class files) This path is the current directory when the command line is run :
java -cp /<snip>/lib/ojdbc14.zip:/<snip>/lib/edtftpj.jar:/path/to/classes gtechReconcile.GtechReconciler
The error then tells me it can't find java.lang.StringBuilder, even though this does not exist in my code. I use a StringBuffer, which apparently StringBuilder has replaced since Java5. Perhaps the java compiler converted this to StringBuilder, which the jvm then does not resolve?
What am I missing here?
EDIT : added error from prompt (clarified where this executes from and what is present in the package folder):
[gtechReconcile]$ pwd
/path/to/
[gtechReconcile]$ cd classes/gtechReconcile/
[gtechReconcile]$ ls
CSVFile.class FTPSender.class GtechReconciler.class QueryMachine.class reports
[gtechReconcile]$ cd ..
[classes]$ ls
gtechReconcile
[classes]$ java -cp .:/path/to/lib/ojdbc14.zip:/path/to/lib/edtftpj.jar gtechReconcile.GtechReconciler
Creating file
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: gtechReconcile.CSVFile
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
at gtechReconcile.GtechReconciler.main(java.lang.String[]) (Unknown Source)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in [file:./, file:/opt/mms_tstt2/gtechReconcile/lib/ojdbc14.zip, file:/opt/mms_tstt2/gtechReconcile/lib/edtftpj.jar, file:/usr/share/java/libgcj-3.4.6.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at _Jv_BytecodeVerifier.verify_instructions_0() (/usr/lib/libgcj.so.5.0.0)
at _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib/libgcj.so.5.0.0)
at _Jv_PrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at _Jv_WaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
...2 more