"Exception in thread "main" java.lang.NoClassDefFoundError: com/aspose/cells/Workbook"

I’m currently trying(!) to evaluate Aspose.Cells for Java in my company. So far i haven’t been succeeding in writing ANY line of code that uses your objects. Gotta admit, i’m totally confused, frustrated and very close to give it up and hand my negative recommendations to the management.

the code i’m trying to run is this:

//---------------------------------------------------------------------------------
import com.aspose.cells.*;
public class Test {

/**
* @param args
*/
public static void main(String[] args)
{
System.out.println(“creating a workbook object…”);
Workbook wb = new Workbook();
}
}
//---------------------------------------------------------------------------------


the classpath is set correctly, but i still keep getting the following:

creating a workbook object…
Exception in thread “main” java.lang.NoClassDefFoundError: com/aspose/cells/Workbook
at Test.main(Test.java:15)
Caused by: java.lang.ClassNotFoundException: com.aspose.cells.Workbook
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)
… 1 more


Any ideas?

thank you

Hi,

Well, I think it must be a problem with your configuration. I mean you are not setting class path to the Aspose.Cells.jar file fine. For your information, our hundreds of users are using Aspose.Cells for Java component in their environments and it works absolutely fine without any issue.

To use the APIs of the component you need to set and add it to its classpath for your java environmental variables or use some editors of java like Eclipse with ease (See some video demos for reference: http://www.aspose.com/documentation/java-components/aspose.cells-for-java/utilize-page-setup-options.html etc.). For setting environmental variables (in WinXp), you may click System icon in Control Panel, click Advanced tab in it, now click Environment Variables button. Now, you may add a new system defined variable named “classpath” and set its value to the valid paths for Aspose.Cells.jar and JRE environments or others etc. e.g “.;%classpath%;e:\Aspose.CellsJava\jdk1_5\Aspose.Cells.jar;e:\Aspose.CellsJava\jdk1_5\dom4j-1.6.1.jar;…”. click ok and close the dialog.

Alternatively, you may set it at runtime at dos prompt in winxp.

Create a Java program.

//---------------------------------------------------------------------------------
import com.aspose.cells.*;
public class Test {

/**
* @param args
*/
public static void main(String[] args)
{
System.out.println(“creating a workbook object…”);
Workbook wb = new Workbook();
System.out.println(“Done!”);

}
}
//-----------------

Compile and run using the command line e.g



javac -classpath %classpath%;e:\Aspose.Cells.jar; Test.java

java -classpath %classpath%;e:\Aspose.Cells.jar; Test

Kindly let us know if you still find any issue. We will check it soon.

Thank you.


First of all, thanks for the quick response.
The thing is that i did set the classpath in million variations with no success.
However, after reading your response i tried setting teh CLASSPATH environment string (even though i’m working on Linux and you described it for WinXP), it did the job!
i set it to exactly the same paths i gave the -cp option. that’s the weird thing :slight_smile:

Thanks again!

Adi

Hi Adi,

Thank you for considering Aspose.

Which version of JDK are you using? From your description, it seems that you have compiled the Test.java successfully. If so, it means that Aspose.Cells.jar can be found by javac and works fine. For classpath setting, please note one thing: -cp option is only applicable for JDK1.5 or later. If you are using JDK1.4, you must use -classpath instead. And to check whether it is an issue of your classpath setting, you can archive your Test.class as a Test.jar and put the jar into the same path where Aspose.Cells.jar is in, then delete Test.class, and run “java … Test” to check whether the Test can be found. Hopefully this will help you identify your issue.

Thank You & Best Regards,