• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Application not working outside Eclipse

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I've just finished an application, writing it in Eclipse. It's purpose is to extract data from a database presenting them on a web page, using an interface/framework called "OpenSpirit" that I have installed on my computer. I've added the "OpenSpirit.jar" file as external library in Eclipse and I can extract any data from the db and the web page builds as it should. However when I tried making a runnable JAR file, and running it from cmd using "java -jar Myjarfile.jar" it fails telling me:

Unable to determine the OpenSpirit framework version. Make sure the build-version.properties exists if running in developement mode

Now before the exception is thrown it actually manage to determine that the OpenSpirit framework is located at C:\Program Files\OpenSpirit, which is correct.
I then tried to copy the content of the files as shown in Eclipse. Removing the "package mypackage;". I placed them in "C:\Java", copying the "OpenSpirit.jar" file to that location also.
Compiling it successfully with:



Then running it (Start.java contains main method):



Yielding a different error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/openspirit/OspRuntimeException
at...


What am I missing here? Why does it work in Eclipse but not outside?
Any help and suggestions will be very appreciated.
Thank you in advance!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You also need to put OpenSpirit.jar in the classpath during execution.
java -cp c:\Java\OpenSpirit.jar;. Start
 
Ola Hansen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works perfectly using the files separately now thank you very much!

edit: I do have another question. I understood it so that Java always checks the present working directory (in this case C:\Java) for files, such as the OpenSpirit.jar, thus using -cp switch shouldn't be needed. Have I misunderstood this?
 
Saloon Keeper
Posts: 24305
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ola Hansen wrote:It works perfectly using the files separately now thank you very much!

edit: I do have another question. I understood it so that Java always checks the present working directory (in this case C:\Java) for files, such as the OpenSpirit.jar, thus using -cp switch shouldn't be needed. Have I misunderstood this?



Yes. Jars are never implicitly included in the classpath. You always have to request them by name. It would require a custom classloader to do otherwise.
reply
    Bookmark Topic Watch Topic
  • New Topic