• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Mig Layout

 
Ranch Hand
Posts: 82
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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.
 
Greenhorn
Posts: 27
  • 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
  • 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.
 
Marshal
Posts: 71087
292
  • 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
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have a new email
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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
  • 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
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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 didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic