• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

using an executable jar file  RSS feed

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that uses classes contained in a jar file for processing Excel spreadsheets (the Java Excel API). This works fine when I run it as:

with my CLASSPATH set to:

I want to "bundle" all my classes for this application into an executable jar file, then run the application from the executable jar file. So I create the executable jar file containing the "mainClass" as:

But when I execute it as:

Java cannot find classes contained in the jxl.jar file:

This class was found when executing directly from the .class file and this file is indeed in the jxl.jar file:

So I have 2 questions:
1) Why isn't jxl.jar found when I try to execute the executable jar file?
2) Is there a way I can add jxl.jar to the executable jar file, so I just need to deliver 1 file?

- Rolf.
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running java - jar ignores classpath. I'm sure "it's not a bug, it's a feature," but I don't know why.

I can think of four ways to do this:

1 - java -cp jxl.jar:ReadPower.jar com.what.ever.ReadPower

2 - unjar jxl then jar it up with your app (may not be ok with jxl developers)

3 - add a classpath entry to your manifest that points to jxl

4 - put jxl.jar in the extensions folder

- and those perl guys thought they invented "there's more than one way to do it."

There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!