Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

is it ok to have jar file inside another jar file

Posted on 2005-04-28
10
Medium Priority
?
289 Views
Last Modified: 2010-03-31
i have problem when i try to execute a executable jar file which inside contains the postgres driver pg74.215.jdbc3.
when i tried to run it using

java -classpath "$CLASSPATH;D:\AbacusWriter\pnrreader2;C:\Program Files\Apache Group\Tomcat 4.1\server\lib\pg74.215.jdbc3.jar;C:\Program Files\Apache Group\Tomcat 4.1\webapps\tvs\WEB-INF\classes"  PnrInterface

it works

but when i try to
javaw -jar -cp ".\pg74.215.jdbc3.jar" pnrreader.jar

i face null pointer exception
0
Comment
Question by:jefcheek
  • 4
  • 3
  • 3
10 Comments
 
LVL 92

Accepted Solution

by:
objects earned 210 total points
ID: 13883756
no, you need to have it external to the jar.
If you're using an executable jar you can specify its relative location using thr Class-Path: attribute in your Manifest
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13883764
There is this:

http://one-jar.sourceforge.net/

But you are generally better doing what objects says :-)

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13884117
You can also simply build the classes into the same jar as your application using Ant. Let me know if you're interested.

btw:

>>java -classpath "$CLASSPATH;

$CLASSPATH won't be resolved as an environment variable by Windows

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 13884137
>> $CLASSPATH won't be resolved as an environment variable by Windows


True, it should be %CLASSPATH%
0
 
LVL 92

Expert Comment

by:objects
ID: 13884273
> You can also simply build the classes into the same jar as your application using Ant.

Though why would you want to, delivering them seperately is nice and simple and makes upgades simpler.
And if you want a single jar, use a custom class loader as tim suggested.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13884341
>>Though why would you want to, delivering them seperately is nice and simple and makes upgades simpler

jefcheek clearly wants to. Having separate files is error prone. Making an upgrade would actually be a cinch using Ant

>>And if you want a single jar, use a custom class loader as tim suggested.

There's nothing wrong with Tim's suggestion, but Ant is a highly reusable tool and investment in using it would pay off in other areas
0
 
LVL 92

Expert Comment

by:objects
ID: 13884369
Actually the questions asks if its ok, it doen't mention its desirable at all :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13884400
Calm down everyone ;-)

We are all right!

Although I am less right than you two ;-)

Personally, I use objects' suggestion of distributing JAR files seperately, as (as objects says) this makes updates generally smaller in size (just your jar, not all the other jars too)

However, CEHJ has a good point about using ANT to build a single consolidated JAR file.

And if you can't be bothered with ANT, and are determined to distribute just a single JAR, then a classloader like I pointed to should help you achieve your goals...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13884423
:-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13892995
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month20 days, 22 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question