Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ClassNotFoundException for JDBCOracleDriver while executing a Jar 1

Status
Not open for further replies.

derHenrik

Programmer
Oct 4, 2007
5
DE
Hello,

this is my first Question ever... I have a tiny program which is working properly in the IDEs Eclipse and JDeveloper. I deployed it and am able to start it, but I couldn't get an DB-connection outside of an IDE yet (output to command-line is normal) although I tried to include the needed drivers (classes12.jar; nls_charset12.jar) into the package or related them with the classpath. I have also tried several JREs and JDKs by now.
I reduced the program as far as I could, the only thing remaining is the DB-connection. I tried the command-line-commands of the JDeveloper on my commandline (those are visible) but gained no output at all. I am facing the same problems on my windows-client as on the solaris-based-server.
Well, I guess there is something the IDEs are doing which I don't know. Could you please help me?

Thanks in advance!
Yours Henrik
 
Your commandline would have been interesting.
How do you specify the classpath?

Nesting jars will not work.

classes12.jar are more or less antique; afaik 12 means Java-1.2 - but if they work for eclipse and JCreator, they must on the commandline.

An easy but not elegant solution:
Put the jars to %JAVA_HOME%/jre/lib/ext/
which is allways searched.

If you specify the classpath with a relativ path, your current working directory is important.

Here is a description - not very entertaining, but not too complicated to jars:



don't visit my homepage:
 
Yeaaahhh, great!

Thank you so much! I tried it the easy, not the elegant way and it works!

I have to use the older Versions, because the whole application is not up-to-date... the server will not be updated for my tiny program.

Okay, my problem is solved, but I'm quite interested in how you came to know that nesting would not work for me, because I was advised to try nesting to get rid of possible version-conflicts. So, what are the conditions for nesting?

Thanks again my friend,
Your Henrik

 
There is no regular condition for nesting.
Nesting is a no-no.

You may nest, but have to write your own classloader - a possible solution but not an easy one, and not a good one.

Here is an introduction to such a classloader:

If this technique would be widely adopted, it would cause serious annoyance.
Think of 10 programs, all containing xy12.jar.
It is a waste of diskspace, and a waste of download bandwith - not really a big problem for most users, but maybe for some.

A big annoyance would be a bug in xy12.jar, which could be solved by an update xy12-a.jar.
Now you would need to find out, which nested jars contain xy12.jar and update all of them.

And nested jars would fast lead to multi-level nesting - a pain to find something.

The advice you became was bad, so ask what kind of version-conflict could be solved with nested jars.
I never experienced a version conflict, which could have been avoided by a nested jar.
If you really would encounter a conflict, the classpath would be the tool, to solve it.
But I don't think you will.

don't visit my homepage:
 
Okay, I see...

Well, I think your statements are reasonable and I got why this quite simple feature is not implemented by Sun yet. But I still wonder why my IDE (JDeveloper from Oracle) allows to nest jar although its not to clever to do so...

Just for people who may encounter the same problem: A comfortable way to nest .jars in a .jar is made possible by the "Fat Jar Eclipse Plugin"


This plugin extracts the sources from the nested jars to build one big flat jar without jar hierarchy in it. The files get rather large, but if someone like me has to deliver a single jar... I tried this one and it works. It also optionally uses the one-jar-function you mentioned, which then produces a jar thats not flat.


Thank you for your effort!
Yours Henrik
 
Did you consider a change in one class? You will have to deliver a new version of the whole big jar ...


Cheers,
Dian
 
Sure, I can imagine non technical users trying to find the command line :)

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top