/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] .jar-file uses .jar-file

Hey

I have a program (.jar-file) that needs another .jar-file. I compile my [FONT=”Courier New”]File.java[/FONT] by:

[CODE]javac -cp .;JAR2.jar File.java[/CODE]

…and that works fine. I also pack my classes into a .jar-file:

[CODE]jar cmvf start.txt File.jar *.class[/CODE]

Now I have two .jar-files: [FONT=”Courier New”]File.jar[/FONT] & [FONT=”Courier New”]JAR2.jar[/FONT].
When I run File.jar, it can’t find classes inside [FONT=”Courier New”]JAR2.jar[/FONT];

[CODE][COLOR=”Red”]java.lang.NoClassDefFoundError[/COLOR][/CODE]

Does anybody know how to fix this? Can I add “[FONT=”Courier New”]-cp .;JAR2.jar[/FONT]” anywhere to start the [FONT=”Courier New”]File.jar[/FONT] correctly?

Thanks in advance!

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@chazzyFeb 12.2009 — you should already be doing

<i>
</i>java -cp .;JAR2.jar;JAR1.jar YourMainClass


I don't like to count on executable JAR's, it's hard to tell what's in the manifest.
Copy linkTweet thisAlerts:
@Totte_chauthorFeb 13.2009 — Well...

I fixed the problem by extracting the second .jar-file to a directory. Then I packed my File.jar by command:
[CODE]jar cmvf start.txt File.jar *.class [COLOR="Red"]dir[/COLOR][/CODE]
The extra classes i need from [FONT="Courier New"]JAR2.jar[/FONT] in my program was extracted and packed in the new [FONT="Courier New"]File.jar[/FONT]. This is not a perfect solution, but it works...
×

Success!

Help @Totte_ch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...