Hey there i am developing java application.
I completed coding part but i am recieving exception in thread main java.lang.noclassdeffounderror
when i ran it. I have searched this through the internet, and could not find suitable answer.
Let me explain what i have done before exporting java program to the executable jar file from eclipse:
I added some jar files to my library so my program could connect a 3rd party program. It runs from a custom Jre which is named SSC and got location in 3rd party program's(SunSystems) location folder.
I wrote the required java code to run the program.
Then i ran the project, which works perfectly when i run from eclipse.
I clicked on project's name then clicked Export. I selected Runnable jar file and Copy required libraries into sub-folder next to generated jar file. I picked correct class from launch configuration. Then clicked finish.
When i ran the jar file from cmd by typing java -jar ssc.jar
It gives me this error:
exception in thread main java.lang.noclassdeffounderror
and some other lines with tag.
What should i do to fix this?
Some documentations say that i need add classpath to program, or edit manifest file etc. I could not figure out how.
I would appreciate your help. Thanks
(Edit)SSC.java class under the demo package. It works when i run from the eclipse:
package demo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import com.systemsunion.ssc.client.*;
public class SSC {
static String HOST="localhost";
static int Port=8080;
public static void main(String[] args) {
try
{
SecurityProvider secman= new SecurityProvider(HOST,true);
String voucher= secman.Authenticate("PKP","").toString();
String sInputPayload="";
String path="C:/SSC temp/temp.txt";
BufferedReader reader= new BufferedReader(new FileReader(path));
BufferedWriter writer= new BufferedWriter(new FileWriter(new File("C:/SSC temp/temp-result.txt")));
String line="";
while((line = reader.readLine()) != null)
{
sInputPayload = sInputPayload + line;
}
try
{
SoapComponent ssc= new SoapComponent(HOST, Port);
ssc.authenticate(voucher);
String result= ssc.execute("Journal", "Import", sInputPayload);
writer.write(result);
writer.newLine();
writer.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Error when i ran the jar file from cmd:
Exception in thread "main" java.lang.NoClassDefFoundError: com/systemsunion/ssc/
client/SoapComponent
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.systemsunion.ssc.client.SoapCom
ponent
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 6 more