Avatar of margant
margant

asked on 

jar project from Borland (preferrably) or command prompt. Have external librarys that needs to be distributed

Hi,

I have a project with a few classes that link to the external jdbc library in my folder on the drive.  I am using JBUIlder X to run and compile the whole thing, I would love to do less propmt commands as possible, i know Eclipse makes a jar file for the project, but I was unable to find the same thing in JBuilder (latest one).

Now I have few classes linking external lib, i want an executable jar. I was suggested not to package external library with my code for copyright reasons, but i still want the the app to run without user getting out and downloading a library himself.

I know about the manifest file, but i am not sure what to do when i have an external library.  Thats what i have there:

Manifest-Version: 1.0
Created-By: 1.4.2_04 (Sun Microsystems Inc.)
Main-Class: Main
Class-Path: C:\Oracle\Ora81\jdbc\lib\classes.zip

not sure if the Class-Path: works though, i am having difficulty running the jar file.

I have generated the jar using
jar.exe cvf app.jar Main.class ref\*.class
added manifest
adding: Main.class(in = 1499) (out= 881)(deflated 41%)
adding: ref/C.class(in = 10195) (out= 5435)(deflated 46%)
adding: ref/B.class(in = 680) (out= 416)(deflated 38%)
adding: ref/X.class(in = 2734) (out= 1349)(deflated 50%)
adding: ref/Y.class(in = 3228) (out= 1644)(deflated 49%)
adding: ref/Z.class(in = 2165) (out= 1179)(deflated 45%)

And am running it :
java.exe -jar app.jar
Exception in thread "main" java.lang.NoClassDefFoundError: Main

Never did the jar before, but i have neen researching this for some time already,
Need help,
Tnx a plenty
-AM
Java

Avatar of undefined
Last Comment
Mick Barry
Avatar of Mick Barry
Mick Barry
Flag of Australia image

> Class-Path: C:\Oracle\Ora81\jdbc\lib\classes.zip

should be a relative (to where run) directory name
Avatar of petmagdy
petmagdy
Flag of Canada image

open u output jar file (with winzip for example) and make sure that the manifest file is the one u provided and it is located inside directory META-INF

also is ur main class inside a package?

also use classes.jar instead of .zip in ur Class-Path
Avatar of Mick Barry
Mick Barry
Flag of Australia image

> jar.exe cvf app.jar Main.class ref\*.class


your also not adding your manifest
command should be:

jar.exe cvmf manifest.mf app.jar Main.class ref\*.class
Avatar of margant
margant

ASKER

I have added a manifest separately using the
umf
option in the jar.exe.

Question at this point the only way I got external library to work is by pasting its actual forlders inside my jar file.
I dont even think the manifest Class-Path: classes.zip works since I have the classes folder inside my jar anyways.

I want to access classes.zip so that the classes are still accessable from within my code which happends to be orcle/jdbc/..

Any suggestions?

-AM
SOLUTION
Avatar of petmagdy
petmagdy
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mick Barry
Mick Barry
Flag of Australia image

I already suggested how to specify the zip in your manifest earier, did you try my suggestion?
Avatar of margant
margant

ASKER

petmagdy,

yea, that compiles and everything .. but when it comes to running i have class not found exception on one of the classes inside oracle lib.

In the code i use oracle.jdbc.driver.OracleDriver() several times
In the project the lib is linked inside by borland, located C:\oracle\ora81\jdbc\, and I have Borland compiling the whole thing.

Now when i make a jar file, i use
Class-Path: classes12.zip or .jar, and copy the lib archive to the same folder when the compiled jar is. Obviously this is a disreptancy because i complied the project with the lib being C:\oracle\ora81\jdbc\, but i still specify it as Class-Path: classes12.zip. Is this ok?

Maybe i need to recompile the project linking to the library thats in the same folder as the main class?
Anything else could have caused this?

Thanks,
AM
Avatar of margant
margant

ASKER

objects,

Is there a problem destributing classes12.jar inside my own jar?

-AM
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

:)
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo