java


java.lang.NoClassDefFoundError, but all jar files are in place


SOLVED, I GOT IT TO WORK
I just completed my first real JAVA program. It is a program which lets you open a .xlsx file and the program extracts data from this file and shows this in a textArea.
In eclipse, the program works totally fine, but the exported jar doesn't. Once the project is exported I open it in CMD with java -jar c://...... and it opens just fine. However when I try to open the excel file I get this error:
Error message
So basically one of the needed .jar files seems not to be available in runtime. However I believe all of the needed poi-3.9 and xmlbeans are available. See this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="src/xmlbeans-2.3.0.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-examples-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-excelant-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-ooxml-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-ooxml-schemas-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/poi-scratchpad-3.9-20121203.jar"/>
<classpathentry exported="true" kind="lib" path="src/log4j-1.2.13.jar"/>
<classpathentry exported="true" kind="lib" path="src/junit-3.8.1.jar"/>
<classpathentry exported="true" kind="lib" path="src/commons-logging-1.1.jar"/>
<classpathentry exported="true" kind="lib" path="commons-collections4-4.1-javadoc.jar"/>
<classpathentry exported="true" kind="lib" path="commons-collections4-4.1.jar"/>
<classpathentry exported="true" kind="lib" path="src/commons-codec-1.5.jar"/>
<classpathentry exported="true" kind="lib" path="poi-ooxml-3.9.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.5.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-lang3-3.4.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/cssparser-0.9.20.jar"/>
<classpathentry exported="true" kind="lib" path="lib/htmlunit-2.23.jar"/>
<classpathentry exported="true" kind="lib" path="lib/htmlunit-core-js-2.23.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpclient-4.5.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpcore-4.4.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/httpmime-4.5.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jetty-io-9.2.18.v20160721.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jetty-util-9.2.18.v20160721.jar"/>
<classpathentry exported="true" kind="lib" path="lib/neko-htmlunit-2.23.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sac-1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/serializer-2.7.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/websocket-api-9.2.18.v20160721.jar"/>
<classpathentry exported="true" kind="lib" path="lib/websocket-client-9.2.18.v20160721.jar"/>
<classpathentry exported="true" kind="lib" path="lib/websocket-common-9.2.18.v20160721.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xalan-2.7.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.11.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/xml-apis-1.4.01.jar"/>
<classpathentry exported="true" kind="lib" path="src/jsoup-1.10.1.jar"/>
<classpathentry exported="true" kind="lib" path="src/dom4j-1.6.1.jar"/>
<classpathentry exported="true" kind="lib" path="src/selenium-server-standalone-3.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="src/stax-api-1.0.1.jar"/>
<classpathentry kind="lib" path="src/poi-ooxml-3.11.jar"/>
<classpathentry exported="true" kind="lib" path="src/xbean-2.0.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
See also my Order and Exporttab in the build path configurations.
Export
Am I missing something? Any help is greatly appreciated!
EDIT:
I made some changes and all necessary jars are in the lib/ folder of my project. If I export jar and view the jar contents with: jar tf "location.jar". I get the following. So I believe this means that everything is exported nicely. Any suggestions on what might be going wrong, because i keep getting the same error.
This is because eclipse reads your class-path dependencies and includes them in the runtime but for running the exported jar through the java -jar command, you will have to add the -cp <your-jar-locations-semicolon-separated> so that jvm knows that the jars are to be included in the class-path while execution.
alternatively, look into building a shaded jar which contains all your dependent jars in the exported jar.

Related Links

What should I import in order to use the setToolTipText() method in java swing?
android - Service need internet connection
can't set Tablayout title in single line
Querying by date in mongo db
Android to PC: Decryption error on JVM while using RSA/ECB/PKCS1Padding
Intellij Idea - Gradle: Execution failed for task ':compileJava'
PayuMoney - Encryption Algorithm SHA-512
SQL MERGE to update or insert values into same table
java mysql db connection
Loading Property File from Filesystem in Jboss Fuse / Karaf throws Nullpointer
NullPointerException adding data to BST
Swing Timer and poor performance (Java, Swing)
How To Exit Infinite Loop Without Pausing Java
IntelliJ: Why can't I use a class from external jar
Jsoup: how to combine HTML classes into a product record during iteration
Nullexception error when trying to populate array list [duplicate]

Categories

HOME
maven
google-chrome-extension
openlayers
zeromq
image-processing
azure-data-factory
nullpointerexception
plot
layout
spring-jdbc
yum
pivotal-cloud-foundry
acquia
in-app-purchase
uber-api
elasticsearch-hadoop
midi
php-7.1
orchardcms
reactive-cocoa
sms-gateway
excel-vba-mac
openedx
dbext
scriptcs
mps
cultureinfo
wpfdatagrid
uninstall
maquette
elasticsearch-net
wtx
google-rich-snippets
http-get
typed.js
openoffice.org
normal-distribution
sequential
qwerty
hot-module-replacement
libvpx
uft-api
sqlite2
email-templates
gzipstream
core-plot
firebase-admin
outlook-api
angular-resource
chain-builder
hendrix
celery-task
gabor-filter
darcs
pg-dump
watchconnectivity
jquery-filter
passport-google-oauth
log4c
autorest
player
lttng
react-native-listview
testng-dataprovider
bluegiga
itextpdf
pyke
prerequisites
computer-algebra-systems
android-listview
system32
dereference
directoryservices
preferences
undefined-reference
bundles
resty-gwt
floating-point-precision
access-rights
ruby-datamapper
comaddin
jelly
wsdl-2.0
distutils
jquery-knob
mt
getmessage
online-compilation
uiviewanimation-curve
custom-backend
tomcat-valve
django-tagging
yetanotherforum
krl
iphone-web-app
mongomapper
html-input
asp.net-profiles
phonon
port-number
windows-live-messenger

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App