Search code examples
javaclasspathmiglayout

How to get MigLayout to work with my project?


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?


Solution

  • 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