/    Sign up×
Community /Pin to ProfileBookmark

Problem creating .jar file

Hello,

I’m not new to Java but this is the first time I’ve really bothered to “Jar up” my classes or create an exe out of them. I’ve tried so many different methods, all of which bring up the same error: “Exception in thread “main” java.lang.NoClassDefFoundError: BoardDesign (wrong name: testProject/BoardDesign).

I’ve tried using JBuilder directlyt create the jar file,
tried using the jar.exe program;
I have a manifest.exe,
and run the command: jar cvmf manifest.txt appName.jar *.class
then try and run it through using java -jar appName.jar but same error as above
Even tried downloading some third party software to do it for me but all come back with same problem.

I have a main method that is being pointed at by manifest file so i just don’t understand why it won’t run; start of main method and class as shown below:

[CODE]public class BoardDesign {
//entry point for application
public static void main(String[] args) {.. }
}[/CODE]

I would be grateful for any help on this one, thanks

to post a comment
Java

9 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliApr 28.2006 — my guess is if everything else is correct then you will need to convert your windows document to a unix format. I ma guessing u are using windows as ur development environment, if so then make sure that your manifest file is converted to unix format and then insert it in the jar.

Second post your manifest file content here as well as directory structure that you have in the classes folder
Copy linkTweet thisAlerts:
@kram044authorApr 29.2006 — Thanks for the reply; the manifest file simply contains:

Main-Class: BoardDesign (with a return after it)

Similarly the file structure is also very simple with just one folder named "testProject" containing all of the class files; they are of the same package - "testproject" but I can't see how that would make a difference to the main class/method not being found.

You are correct, I am using Windows environment but how do you mean make sure that your manifest file is converted to unix format[/QUOTE]

Thanks
Copy linkTweet thisAlerts:
@Khalid_AliApr 29.2006 — see u mentioned that BoardDesign is in a package "testproject", however that is not referenced in the manifest file...

[b]Main-Class: BoardDesign [/b]

it should be

[b]Main-Class: testproject.BoardDesign [/b]

If that does not work, then let me know and I will be able to create a manifest file and make sure it works and then upload for u
Copy linkTweet thisAlerts:
@kram044authorApr 29.2006 — Tried previously with the Main-Class: testproject.BoardDesign (just tried again now as well) with no joy i'm afraid - same problem stating: Exception in thread "main" java.lang.NoClassDefFoundError:testproject/BoardDesign

Sorry
Copy linkTweet thisAlerts:
@Khalid_AliApr 30.2006 — as I mentioned in the previous post..anyways..here is the working manifest file. just download it and use in ur jar command to insert in jar file....

Make sure that u don't make any changes until u run it once.

I think what u are facing is, typical windows related problem where a simple file may contain some BOM or anything of that sort, when u save the file in unix format they are removed.

[upl-file uuid=840c3f5f-688a-4675-a94f-5c8993bea59a size=554B]manifest.zip[/upl-file]
Copy linkTweet thisAlerts:
@kram044authorApr 30.2006 — Hate to be a pain but i'm getting the same error message with the provided manifest file as well.


I've got this setup right haven't i - I have the jar.exe program in the same folder as my .classes and then use command prompt to run the exe file using jar cvmf manifest.mf pubQuiz.jar *.class

File structure is setup as in the attachment (with the classes and jar.exe being in the highlighted folder).

[upl-file uuid=33d21856-d3fe-42a1-9cad-0e42ac18bcf3 size=8kB]fileStructure.JPG[/upl-file]
Copy linkTweet thisAlerts:
@Khalid_AliApr 30.2006 — [b]jar cvmf manifest.mf pubQuiz.jar *.class[/b]

the above is wrong if you are running it from ur classes folder, because ur classes are actually under the testproject folder. what u need to do is suppose ur directory structure is as follows

[code=php]
classes/
testproject
/*.class
[/code]

so now cd to classes

at the prompt it should say something like below considering ur root drive is C:/ and u have ur java projects files under the folder java

cd C:javaclasses

now ur prmpt will show u this

C:javaclasses>

enter the jar command

[b]C:javaclasses>jar cvmf manifest.mf designBoard.jar testproject/*.*[/b]

Above will create the jar file now u can run it using the following line

[b]C:javaclasses>java -jar designBoard.jar[/b]

Hope this helps
Copy linkTweet thisAlerts:
@kram044authorApr 30.2006 — I could almost kiss you - by the looks of things the Jar file has been built correctly... just getting a secondary error regarding com/borland/jbcl/layout/XYLayout not being found.

Although I would expect that because I've moved to my work computer (where jbuilder isn't installed) rather than home one.

Presumably if i run through the same steps as above then the whole thing should come together nicely. Only one slight worry... if I move this jar file around is it still going to be looking for "com/borland/jbcl/layout/XYLayout"??


If so can i incorporate it in to the jar file somehow?

Thanks for all your help
Copy linkTweet thisAlerts:
@Khalid_AliApr 30.2006 — yes in that case you will need to put any additional classes/jar files in the lib folder within the jar file and make this entry in the manifest file that where are the additional files. Just read thru the jar file docs at java.sun.com and that should help u in that aspect...

Glad that it works for u...Happy to be of some help
×

Success!

Help @kram044 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...