This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mig Layout

 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i�m using miglayout in a little project, works great when i execute my gui in eclipse 3.3, but when i export the project into a jar file, it gives me "NoClassDefFoundError: net/miginfocom/swing", i dont know how to solve it since i have added the miglayout-3.6-swing.jar to the proyect classpath.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When running java applications outside of the IDE you still need to specify the classpath. The most common way is while executing from the command line:

java -classpath library.jar -jar app.jar

So make sure your miglayout jar file is specified in the classpath as noted above.
 
Pavan Kumar Srinivasan
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the standard jdk jar(rt.jar) is not on your classpath, considering it is not a ClassNotFoundException but a NoClassDefFoundError which your are getting.
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've tried java -classpath miglayout-3.6-swing.jar -jar miproyect.jar
and also java -classpath miglayout-3.6.jar -jar myproject.jar, still not working, i have another version of the same proyect that dont use any external libraries and works fine.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need rt.jar in your classpath, at least not for recent versions of Java.

One thing I have tried is copying the .jar into the current directory where you can start your application by writing java foo.bar.MyClass, then unzipping the .jar. You then have the jar folders in the same directory as your own folders, and it is a naughty cheat technique, but seems to work.
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've decompressed the jar that eclipse generated, this is the dir structure:
.settings -->dir
META-INF --> containing manifest indicating the main class
controller --> dir
model --> dir
view --> dir, where the miglayout.jar is needed, so i've put the miglayout.jar here
.classpath --> file
.project --> file

Then i've created a new jar --> jar cmf META-INF\MANIFEST.MF MyProject.jar * But still have the same error message
[ November 08, 2008: Message edited by: Jorge Bendahan ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jorge, is it possible for you to provide access to your JAR file? I'd be happy to test it out on my machine to see if I can get it working.

One thing to remember is by typing

java -classpath miglayout-3.6-swing.jar -jar miproyect.jar

you are saying that miglayout-3.6.swing.jar and miproyect.jar are both in the directory where you are running the java command from. If either are in different locations you need to provide the absolute path to either/both. So something like:

java -classpath /path/to/miglayout.jar -jar miproyect.jar
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'll be happy to, give me your email address and i'll send it over.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jorge Bendahan:
i'll be happy to, give me your email address and i'll send it over.


Check your private messages.
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have a new email
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I think I have figured out the problem. I was running into the same problem as you were. Then I realized that we are using the MANIFEST file to specify the main class. By doing this the -classpath switch pretty much gets ignored. So you have to tell the MANIFEST file what your classpath is. After doing this, it worked for me. Your new MANIFEST file should look like this:

Manifest-Version: 1.0
Main-Class: vista.Principal
Class-Path: miglayout-3.6-swing.jar

And then, assuming miglayout-3.6-swing.jar and myproyect.jar are in the same path...

java -jar mypryect.jar

And you should be good to go.
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Gregg, now it works!
 
Jorge Bendahan
Ranch Hand
Posts: 82
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg actually took the time to examine the jar file and found the problem , i apologize for the code, pretty bad yet. But i'm learning, i must add threads to the gui and other major improvements. Thanks again.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jorge Bendahan:
Gregg actually took the time to examine the jar file and found the problem , i apologize for the code, pretty bad yet. But i'm learning, i must add threads to the gui and other major improvements. Thanks again.


No problem at all. Glad I could help. My biggest hurdle was not knowing spanish.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic