views:

600

answers:

3

I'm trying to make a small GUI app and I want to use MigLayout with it. As Java newbie I don't know how to get MigLayout to work with my code and I'm running out of ideas.

My project source code is in ~/git/project/src/qdb/

The qdb is my java package name. I downloaded miglayout-3.7-swing.jar and miglayout-3.7.jar and placed them to my project sources and tried to compile the code but I get errors pointing to "new MigLayout()" stating "cannot find symbol".

I was in src dir and used "javac qdb/*.java" to compile (* gets expanded). I also tried to point classpath to my sources like: "javac -classpath /home/user/git/project/src/qdb/ qdb/*.java" but I still get the error.

Then I've also tried to put the jar files to ~/jars/ and use that as classpath but still the same error follows.

So, how to get MigLayout working?

+1  A: 

Simply add the miglayout-3.7-swing.jar to your classpath:

javac -classpath /your/path/to/miglayout-3.7-swing.jar qdb/*.java

(as illustrating in this thread Installing Mig Layout)


If you can compile them (with the above line),
but can not execute the resulting program, you also need to add to the java classpath the library

java -classpath /your/path/to/miglayout-3.7-swing.jar:/your/project/compiledClass/dir qdb.yourMainClass
VonC
Also gives same error message.
Zmyrgel
What is the exact command line your are typing ?
VonC
Ah, got it to working after deleting the other jar files and trying again.Really should check out ant or something instead of manually typing these commands all the time. Thanks for your help.
Zmyrgel
You are welcome :)
VonC
+1  A: 

If you are going to put it into a .jar file, you'll need to specify the Class-Path in the manifest file:

Class-Path: /your/path/to/miglayout.jar

Jason Gin
+1  A: 

VonC's answer is right. I just want to add (since you are a Java newbie) that you should consider developing using an IDE. They'll save you hours of by-hand-compiling, and will help you integrate your code with libraries (such as MigLayout) more easily.

There are two free IDEs I really like:

IBM's Eclipse.

SUN's (soon to be IBM's) Netbeans.

Also consider this SO thread. And this one too.

Good luck.

Pablo Santa Cruz