where are my mistakes? - java

I have a problem with reading excel file and analyze it through apache poi 3.9... I added the external JAR file but it still gives me errors. Here my codes
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class loop {
public static void main(String [] args) throws Exception
{
File excel= new File("C:\\Users\\songSent.xlsx");
FileInputStream fis= new FileInputStream(excel);
XSSFWorkbook wb= new XSSFWorkbook(fis);
XSSFSheet ws= wb.getSheet("Input");
int rowNum=ws.getLastRowNum() +1;
int colNum=ws.getRow(0).getLastCellNum();
String [][] data= new String[rowNum][colNum];
for(int i=0; i<rowNum; i++)
{
XSSFRow row= ws.getRow(i);
for(int j=0; j<colNum; j++)
{
XSSFCell cell=row.getCell(j);
String value=cellToString(cell);
data[i][j]=value;
System.out.println("the value is " +value);
}
}
}
public static String cellToString(XSSFCell cell)
{
int type;
Object result;
type=cell.getCellType();
switch (type){
case 0:
result=cell.getNumericCellValue();
break;
case 1:
result=cell.getStringCellValue();
break;
default:
throw new RuntimeException("There no support");
}
return result.toString();
}
}
and these are the errors when I run the program
Exception in thread "main" java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFCell
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:org.apache.poi.hssf.usermodel.HSSFCell
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

It is pretty clear from the stack trace that your program is not able to find "poi" jar. Check if your classpath is set correctly & if you are running from eclipse (or some other IDE) check if jar is added to the build path.

At runtime, you're missing at least some of the Apache POI jars. Specifically, you're missing the main poi jar (eg poi-3.10-beta2-20130904.jar), and quite possibly some others too.
Firstly, you need to remember that with Java, your jars need to be available both at compile time and at runtime. Just having the jar on your classpath when you compile isn't enough, you also still need to put them on the classpath at runtime!
Secondly, you'll need to ensure that you include the Apache POI jars as appropriate for the POI components you're using, along with any dependencies those components have. That's all documented on the Apache POI components page, which explains which Jars hold which components, and what dependencies those have.
(Since you're using XSSF, that means you need the main poi jar, the poi-ooxml jar, the poi-ooxml-schemas jar, and their dependencies)

Related

Loading ontology to extract all the imported name spaces

I am trying to load an ontology saved on my PC. The file format is .n3.
After a lot of work and searching for the possible solutions, I didn't find an appropriate way to load an ontology.
I tried the following code:
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.model.OWLModel;
public class Extractor {
public static void main(String[] args) {
String ontologyURI = "file:///C:/acco.n3";
try {
OWLModel owlModel = ProtegeOWL.createJenaOWLModelFromURI(ontologyURI);
System.out.println("Worked");
}catch (Exception exception) {
System.out.println("Error can't upload the ontologie ");
}
}
}
but it always gives me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.hp.hpl.jena.graph.Node.<clinit>(Node.java:35)
at com.hp.hpl.jena.rdf.model.impl.ResourceImpl.fresh(ResourceImpl.java:108)
at com.hp.hpl.jena.rdf.model.impl.ResourceImpl.<init>(ResourceImpl.java:68)
at com.hp.hpl.jena.rdf.model.ResourceFactory$Impl.createResource(ResourceFactory.java:176)
at com.hp.hpl.jena.rdf.model.ResourceFactory.createResource(ResourceFactory.java:69)
at com.hp.hpl.jena.vocabulary.RDF.resource(RDF.java:29)
at com.hp.hpl.jena.vocabulary.RDF.<clinit>(RDF.java:37)
at com.hp.hpl.jena.datatypes.xsd.impl.XMLLiteralType.<clinit>(XMLLiteralType.java:30)
at com.hp.hpl.jena.datatypes.TypeMapper.<clinit>(TypeMapper.java:52)
at edu.stanford.smi.protegex.owl.model.impl.OWLSystemFrames.createRDFSDatatypes(Unknown Source)
at edu.stanford.smi.protegex.owl.model.impl.OWLSystemFrames.createOWLInstances(Unknown Source)
at edu.stanford.smi.protegex.owl.model.impl.OWLSystemFrames.createOWLMetaModel(Unknown Source)
at edu.stanford.smi.protegex.owl.model.impl.OWLSystemFrames.<init>(Unknown Source)
at edu.stanford.smi.protegex.owl.swrl.SWRLSystemFrames.<init>(Unknown Source)
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.createSystemFrames(Unknown Source)
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.createSystemFrames(Unknown Source)
at edu.stanford.smi.protege.model.DefaultKnowledgeBase.<init>(DefaultKnowledgeBase.java:79)
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.<init>(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.<init>(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.createKnowledgeBase(Unknown Source)
at edu.stanford.smi.protege.model.Project.createDomainKB(Project.java:429)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:447)
at edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(Unknown Source)
at Extractor.main(Extractor.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 25 more
I need your help in solving this error, or perhaps find a way to load ontologies to extract knowledge from them.
Thanks in advance.
Update:
I added the missing dependencies to the class path as #Roddy of the Frozen Peas suggested.
but it gives me the following error:
WARNING: [Local Folder Repository] The specified file must be a directory. (C:\eclipse-workspace\NewEx\plugins\edu.stanford.smi.protegex.owl) -- LocalFolderRepository.update()
Exception in thread "main" java.lang.NoClassDefFoundError: org/protege/editor/owl/model/hierarchy/roots/Relation
at edu.stanford.smi.protegex.owl.jena.parser.TripleProcessor.<init>(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.parser.GlobalParserCache.getTripleProcessor(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.loadTriples(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.parser.ProtegeOWLParser.run(Unknown Source)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.loadKnowledgeBase(Unknown Source)
at edu.stanford.smi.protege.model.Project.loadDomainKB(Project.java:1346)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:456)
at edu.stanford.smi.protegex.owl.jena.creator.OwlProjectFromUriCreator.create(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModelFromURI(Unknown Source)
at Extractor.main(Extractor.java:10)
Caused by: java.lang.ClassNotFoundException: org.protege.editor.owl.model.hierarchy.roots.Relation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 10 more
any suggestions please?
java.lang.ClassNotFoundException: org.protege.editor.owl.model.hierarchy.roots.Relation
There are other dependencies you need. Rather than going piecemeal, you should use a build system that can resolve the dependency closure for you, such as Maven, Gradle or similar.
The problem here is not Protege specific or ontology related, it's just plain Java libraries missing from the classpath.
Note that your code does not use OWL API. These classes are Jena classes and Protege classes (from Protege 3.x, I'd think). Note that Protege 3.x is a very dated API. Consider using a newer version (5.2.0 or newer), or directly using the actual OWL API. See https://github.com/owlcs/owlapi/wiki/Documentation
OWL API also has zip files containing all dependencies, which might simplify your work (Maven is still better than resolving dependencies by hand). See https://github.com/owlcs/releases/tree/master/owlapi/5

java.lang.NoClassDefFoundError: com/healthmarketscience/jackcess/util/ErrorHandler in ms access connectivity with java8

I am trying to connect Ms Access database with java 8 version. But as in this version jdbcodbcbridge driver has been removed, so following jar files need to be included :
**ucanaccess-x.x.x.jar
HSQLDB (hsqldb.jar, version 2.2.5 or newer)
,Jackcess (jackcess-2.x.x.jar)
,commons-lang (commons-lang-2.6.jar, or newer 2.x version)
,commons-logging (commons-logging-1.1.1.jar, or newer 1.x version)**
I have bought all these jar files in my eclipse through Build Path option.
But still when i am executing the following code it is coming up with error as:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/healthmarketscience/jackcess/util/ErrorHandler at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Unknown Source) at
demo.JDBCDemo.main(JDBCDemo.java:11) Caused by:
java.lang.ClassNotFoundException:
com.healthmarketscience.jackcess.util.ErrorHandler at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) ... 3 more
And my code is:
import java.sql.*;
import java.util.*;
import com.healthmarketscience.jackcess.util.ErrorHandler;
public class JDBCDemo {
public static void main(String args[]) throws Exception
{
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\isha\\Desktop\\StudentData.accdb");
Statement stmt=con.createStatement();
String str="insert into NameData values(4,'ram')";
stmt.executeUpdate(str);
String s="select * from NameData";
ResultSet res=stmt.executeQuery(s);
while(res.next()){
System.out.println(res.getString(1)+":"+res.getString(2));
Enumeration e=DriverManager.getDrivers();
while(e.hasMoreElements()){
Driver d=(Driver)e.nextElement();
System.out.println(d.getClass().getName());
}
}
}
}
You have an old obsolete version of jackcess in your classpath. Please add to your classpath ucanaccess.jar the jars in the folder lib of the specific ucanaccess distribution you're using.
String str="insert into NameData values(4,'ram')";
in which columns you insert this values?

Docx4j loading docx is giving NullPointerException

I wanted to convert docx to html. I started writing the code same as examples given in github. This is just loading part. There itself I'm getting the problem.
import org.docx4j.Docx4J;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
public class Main {
public static void main(String[] args) throws Docx4JException,
String inputfilepath = "myfilepathhere";
OutputStream os = new FileOutputStream(inputfilepath + ".html");
WordprocessingMLPackage wordMLPackage = Docx4J
.load(new FileInputStream(inputfilepath));
}
}
I'm getting NullPointerException. Seeing the exception trace and navigating in source code in github, I suspect it has something to do with JAXB related thing from this class https://github.com/plutext/docx4j/blob/master/src/main/java/org/docx4j/jaxb/Context.java
Docx4j source code is available at https://github.com/plutext/docx4j.
Exception trace:
Exception in thread "main" org.docx4j.openpackaging.exceptions.Docx4JException: Couldn't get [Content_Types].xml from ZipFile
at org.docx4j.openpackaging.io3.Load3.get(Load3.java:134)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:454)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:371)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:337)
at org.docx4j.openpackaging.packages.OpcPackage.load(OpcPackage.java:302)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(WordprocessingMLPackage.java:170)
at org.docx4j.Docx4J.load(Docx4J.java:195)
at Main.main(Main.java:29)
Caused by: org.docx4j.openpackaging.exceptions.InvalidFormatException: Bad [Content_Types].xml
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:713)
at org.docx4j.openpackaging.io3.Load3.get(Load3.java:132)
... 7 more
Caused by: java.lang.NullPointerException
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:679)
... 8 more
The docx document is good (created by Word 2010). I've even unzipped it to see if the Content_Types.xml is there. It's there.
I'm using Eclipse and Java SE 7. I've added all the required jar files to Java build path in project properties.
Please help me.
Update:
Actually when I added this line from Context.java into my class to see if that's the problem.
JAXBContext.newInstance("org.docx4j.openpackaging.contenttype");
I could see the following exception in my console:
Exception in thread "main" javax.xml.bind.JAXBException: Provider org.eclipse.persistence.jaxb.JAXBContextFactory not found
- with linked exception:
[java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory]
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at Main.main(Main.java:26)
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.jaxb.JAXBContextFactory
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)
at javax.xml.bind.ContextFinder.safeLoadClass(Unknown Source)
... 6 more
docx4j supports several different JAXB implementations:
the reference implementation
the one Sun/Oracle include in Java 6/7/8
EclipseLink MOXy
If you want to use MOXy, you need:
the relevant EclipseLink jars
docx4j-MOXy-JAXBContext-3.0.0.jar (which just contains the jaxb.properties files)
The jaxb.properties files just say:
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
If you are using maven, you'll just need to add:
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-MOXy-JAXBContext</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.5.1</version>
</dependency>
Is the docx4j-MOXy-JAXBContext jar on your classpath? Either remove it, or add the relevant EclipseLink jars
This works for me, try this out
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.docx4j.Docx4J;
import org.docx4j.Docx4jProperties;
import org.docx4j.convert.out.HTMLSettings;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
public class Test {
public static void main(String[] args) throws Docx4JException,
FileNotFoundException {
String inputfilepath = "c:/file.docx";
WordprocessingMLPackage wordMLPackage = Docx4J
.load(new FileInputStream(inputfilepath));
// HTML exporter setup (required)
//.. the HTMLSettings object
HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
htmlSettings.setImageDirPath(inputfilepath + "_files");
htmlSettings.setImageTargetUri(inputfilepath.substring(inputfilepath
.lastIndexOf("/") + 1) + "_files");
htmlSettings.setWmlPackage(wordMLPackage);
OutputStream os = new FileOutputStream(inputfilepath + ".html");
// If you want XHTML output
Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);
//Prefer the exporter, that uses a xsl transformation
Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
}
}
Ensure you've all the right dependencies (including the appropriate JAXB Runtime)
implementation 'org.docx4j:docx4j-core:11.4.7'
implementation 'org.docx4j:docx4j-MOXy-JAXBContext:6.0.0'
implementation 'org.docx4j:docx4j-export-fo:11.4.7'
implementation 'org.docx4j:docx4j-JAXB-Internal:8.3.8'
implementation 'org.docx4j:docx4j-JAXB-ReferenceImpl:11.4.7'
implementation 'org.docx4j:docx4j-JAXB-MOXy:11.4.7'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.0'
implementation 'jakarta.activation:jakarta.activation-api:2.1.0'

java.lang.NoClassDefFoundError when Translating

I am using the Apertium Translator and using the sample code they provide. My code is like this.
import com.robtheis.aptr.language.Language;
import com.robtheis.aptr.translate.Translate;
public class Test {
public static void main(String[] args) throws Exception {
// Set the Apertium API Key - Get yours at http://api.apertium.org/register.jsp
Translate.setKey("BNSCFhEL8DoTApc2I1+aa3UYkVg");
String translatedText = Translate.execute("Hola, mundo!", Language.SPANISH, Language.ENGLISH);
System.out.println(translatedText);
}
}
I have no errors or warnings and when I run the program I get the following errors.
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONValue
at com.robtheis.aptr.ApertiumTranslatorAPI.jsonSubObjToString(ApertiumTranslatorAPI.java:195)
at com.robtheis.aptr.ApertiumTranslatorAPI.retrieveSubObjString(ApertiumTranslatorAPI.java:140)
at com.robtheis.aptr.translate.Translate.execute(Translate.java:56)
at maple.Test.main(Test.java:11)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONValue
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)
... 4 more
The .jar I'm using is the second one from https://github.com/rmtheis/apertium-translator-java-api/downloads
You have to download the first one. The first jar file (apertium-translator-java-api-0.2-jar-with-dependencies.jar) contains the all dependencies needed..
Or you add a json library to your project path..
Well JVM is not able to find some class at Runtime which was available at compile time. That is the reason of NoClassDefFoundError
Below you also have ClassNotFoundException for this class org.json.simple.JSONValue
which means you are trying to load the particular class at run-time by name.
Both of them related to Java Class Path.
I don't know alot about jSON stuff. But you are missing this file org.json.simple.JSONValue you can take it from here http://code.google.com/p/json-simple/
add the above jar file in your class path . And the code will definitely run. Guaranteed.!!!
Thanks

How do a I resolve a java jackcess dependence error?

I'm tring to dispaly data from an MS Access db, I'm useing Jackcess library but I get a dependence error that I do not how to resolve. Here is my code and error:
import com.healthmarketscience.jackcess.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.nio.*;
import java.lang.*;
import org.apache.commons.*;
import org.apache.commons.lang3.builder.*;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
class Main {
private static Logger log=Logger.getLogger(Main.class);
public static void main(String args[]) {
DOMConfigurator.configure("lib\\log4j.xml");
try {
Database d = Database.open(new File("lib\\ExTables.mdb"));
System.out.println(d.getTable("Cliente").display());
} catch(Exception e) {
e.printStackTrace();
}
}
}
Here is my error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder
at com.healthmarketscience.jackcess.RowId.compareTo(RowId.java:108)
at com.healthmarketscience.jackcess.IndexData$Entry.compareTo(IndexData.java:1825)
at com.healthmarketscience.jackcess.IndexData$Entry.compareTo(IndexData.java:1637)
at java.util.Collections.indexedBinarySearch(Unknown Source)
at java.util.Collections.binarySearch(Unknown Source)
at com.healthmarketscience.jackcess.IndexData$DataPage.findEntry(IndexData.java:2347)
at com.healthmarketscience.jackcess.IndexData.findEntryPosition(IndexData.java:709)
at com.healthmarketscience.jackcess.IndexData.access$3100(IndexData.java:54)
at com.healthmarketscience.jackcess.IndexData$EntryCursor.updatePosition(IndexData.java:2118)
at com.healthmarketscience.jackcess.IndexData$EntryCursor.restorePosition(IndexData.java:2057)
at com.healthmarketscience.jackcess.IndexData$EntryCursor.restorePosition(IndexData.java:2040)
at com.healthmarketscience.jackcess.IndexData$EntryCursor.beforeEntry(IndexData.java:2002)
at com.healthmarketscience.jackcess.IndexCursor.findPotentialRow(IndexCursor.java:439)
at com.healthmarketscience.jackcess.IndexCursor.findRowByEntryImpl(IndexCursor.java:342)
at com.healthmarketscience.jackcess.IndexCursor.findRowByEntry(IndexCursor.java:175)
at com.healthmarketscience.jackcess.Database$DefaultTableFinder.findRow(Database.java:2239)
at com.healthmarketscience.jackcess.Database$TableFinder.findObjectId(Database.java:2168)
at com.healthmarketscience.jackcess.Database.readSystemCatalog(Database.java:1081)
at com.healthmarketscience.jackcess.Database.<init>(Database.java:765)
at com.healthmarketscience.jackcess.Database.open(Database.java:589)
at com.healthmarketscience.jackcess.Database.open(Database.java:535)
at com.healthmarketscience.jackcess.Database.open(Database.java:510)
at com.healthmarketscience.jackcess.Database.open(Database.java:488)
at com.healthmarketscience.jackcess.Database.open(Database.java:467)
at Main.main(Main.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.builder.CompareToBuilder
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)
... 25 more
That's my command line:
C:\Programmi\Java\jre6\bin\javaw.exe -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:3280 -Dfile.encoding=Cp1252 -classpath "C:\Documents and Settings\linosa\Documenti\programmazione\workspace_java\MSAccess\bin;C:\Documents and Settings\linosa\Documenti\programmazione\workspace_java\MSAccess\lib\jackcess-1.2.5.jar;C:\Documents and Settings\linosa\Documenti\programmazione\workspace_java\MSAccess\lib\log4j-1.2.16.jar;C:\Documents and Settings\linosa\Documenti\programmazione\workspace_java\MSAccess\lib\commons-logging-1.1.1.jar;C:\Documents and Settings\linosa\Documenti\programmazione\workspace_java\MSAccess\lib\junit-4.10.jar;C:\Documents and Settings\linosa\Documenti\programmazione\commons-lang3-3.1-bin\commons-lang3-3.1\commons-lang3-3.1-tests.jar;C:\Documents and Settings\linosa\Documenti\programmazione\commons-lang3-3.1-bin\commons-lang3-3.1\commons-lang3-3.1.jar;C:\Documents and Settings\linosa\Documenti\programmazione\commons-lang3-3.1-bin\commons-lang3-3.1\commons-lang3-3.1-javadoc.jar;C:\Documents and Settings\linosa\Documenti\programmazione\commons-lang3-3.1-bin\commons-lang3-3.1\commons-lang3-3.1-sources.jar" Main
Commons Lang 3 is not backward compatible with 2.x. You'll have to download 2.6.
You might also want to investigate Maven or Ant+Ivy to make this kind of dependency resolution a bit easier.
Found it ;-) The commons lang is in the classpath, but it seems to be the wrong version.
The requested package is org.apache.commons.lang.builder, which is valid for commons-lang 2.x in commons-lang3 the package is 'org.apache.commons.lang3.builder'. So you have to include a commons-lang 2.x

Categories