Results 1 to 14 of 14
  1. #1
    DC200 is offline Member
    Join Date
    Dec 2008
    Posts
    49
    Rep Power
    0

    Default Installing Java libraries

    I'm writing a little application that will be required to read Excel spreadsheets, and so I've decided to use the JExcelAPI to accommodate that function.

    When I compile and pack the application into an executable jar, will others be able to run it with only JVM installed on their computers? Or will they require JDK and/or JExcelAPI installed as well? The latter option would be pretty troublesome for the users, and I'd rather keep that as a last resort.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    the users would be able to work with a JVM runtime, not needing the JDK.

    they will however also need the JExcelAPI jar file.
    You can configure the manifest of your executable jar file to set the class path to include their jar file, this usually assumes the current working directory at the time the executable jar file is launched is that where the jar file is and the jexcel api is in the same or well known relative location relative to your executable jar file.

    or create a batch file or shell script that would set up a command line or class path to include the required jar files and invoke the main() in your jar.

  3. #3
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Your users will definitely need the jExcelApi JAR file(s). Is this an in-house project, or something you're selling, or developing on contract, or what? The reason I ask is because jExcelApi is GPL, and if licensing is a consideration you may prefer to use the Apache-licensed POI library.

    -Gary-

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    I think Apache POI is much better, both in the performance/processing as well as with the licensing stuff for commercial aspect. Actually you can include those required additional libraries with the package. Then no nee to ask from user to download and do mess-up things. But you have to care of configuring those things properly, means that setup the classpath for all JARs.

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default


    what's about to but additional jars in ..\lib\ext of java? shouldn't these jars be found by default?

  6. #6
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by j2me64 View Post
    what's about to but additional jars in ..\lib\ext of java? shouldn't these jars be found by default?

    yes it is. i found an answer on my question here How Classes are Found

  7. #7
    DC200 is offline Member
    Join Date
    Dec 2008
    Posts
    49
    Rep Power
    0

    Default

    I've considered Apache POI as well, but I'd like to give JExcelAPI a try as it seems a tad bit simpler to use. Anyway, I've copied the package over to lib/ext/ and have also imported the package successfully with import jxl.*, but I'm unable to run any of the example code. The code Workbook workbook = Workbook.getWorkbook(new File("test.xls")) compiles fine, but generates the following runtime error.

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: jxl/Workbook
    	at demo.main(demo.java:10)
    Caused by: java.lang.ClassNotFoundException: jxl.Workbook
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    	... 1 more
    Last edited by DC200; 03-20-2010 at 01:35 AM.

  8. #8
    DC200 is offline Member
    Join Date
    Dec 2008
    Posts
    49
    Rep Power
    0

    Default

    Quote Originally Posted by DC200 View Post
    I've considered Apache POI as well, but I'd like to give JExcelAPI a try as it seems a tad bit simpler to use. Anyway, I've copied the package over to lib/ext/ and have also imported the package successfully with import jxl.*, but I'm unable to run any of the example code. The code Workbook workbook = Workbook.getWorkbook(new File("test.xls")) compiles fine, but generates the following runtime error.

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: jxl/Workbook
    	at demo.main(demo.java:10)
    Caused by: java.lang.ClassNotFoundException: jxl.Workbook
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    	... 1 more
    Anyone? I still haven't been able to resolve this error and I need to get started with the coding as soon as possible.

    All I need at the moment is for my code to run properly. I'll think about packing the jar and modifying the manifest for jxl later.

  9. #9
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    You might consider re-posting in a different forum (maybe Other APIs?) under a different title. You might get a look from people who know the jExcelAPI library that way. Let them know that it's a cross-post from here, of course.

    -Gary-

  10. #10
    DC200 is offline Member
    Join Date
    Dec 2008
    Posts
    49
    Rep Power
    0

    Default

    Posted new thread: http://www.java-forums.org/database/...tml#post110330

    Found a temporary solution shortly afterwards. :)

  11. #11
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Are you using an IDE? I know some of the gurus here recommend plain text editors and manual compile tools while you're learning, and I understand their reasons, but you might want to check out Eclipse and the short tutorial here: Eclipse and Java for Total Beginners It's for an older version of Eclipse, but everything still applies with perhaps a few very minor changes. The reason I bring it up is because an IDE like Eclipse can dramatically simplify things like including external JARs.

    -Gary-

  12. #12
    DC200 is offline Member
    Join Date
    Dec 2008
    Posts
    49
    Rep Power
    0

    Default

    No, I'm not using an IDE at the moment. Do they also simplify the creation of executable jar files with libraries automatically added to the manifest?

  13. #13
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by DC200 View Post
    No, I'm not using an IDE at the moment. Do they also simplify the creation of executable jar files with libraries automatically added to the manifest?
    Yes, very much so. When you have some time, check out that tutorial, and another one by the same guy about Java Persistence.

    -Gary-

  14. #14
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default

    NetBeans can create a dist folder with a lib subfolder that holds all your linked jars, and a manifest file with all needed information. All you have to do is distribute the entire contents of the dist folder ... heck, the IDE even creates a README.txt that tells you so.

    That said, it would be a good idea to go through the jar deployment tutorial so you understand the output of the IDE.
    Lesson: Packaging Programs in JAR Files (The Java™ Tutorials > Deployment)

    db

Similar Threads

  1. Installing a new Java Package
    By tyang in forum New To Java
    Replies: 8
    Last Post: 02-24-2010, 06:22 PM
  2. Need Help installing java - can you help me?
    By Menre in forum New To Java
    Replies: 4
    Last Post: 02-22-2010, 01:33 PM
  3. Java Media Libraries
    By SilentCodingOne in forum Advanced Java
    Replies: 2
    Last Post: 07-04-2009, 06:21 AM
  4. Java 3D Scene Graph Libraries
    By sweeyt in forum AWT / Swing
    Replies: 1
    Last Post: 04-10-2009, 09:26 AM
  5. Installing Java
    By Adv3nt in forum New To Java
    Replies: 3
    Last Post: 12-13-2007, 12:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •