I'm usually working in Eclipse. In my program, I'm using this miglayout-4.0-swing.jar file from this source: link.
Somehere in the .jar file is class with MigLayout.
I use these imports:
import net.miginfocom.layout.Grid;
import net.miginfocom.swing.MigLayout;
//It's from the jar file.
In Eclipse i just add library:
Java Build Path -> Libraries -> Add JARs/Add external JARs -> path to miglayout-4.0-swing.jar
So in Everything working.
But I need to run it from terminal: java (I don't use packages so i use just classes from bin) but there is the problem with the .jar file, cause myMain class probably don't know where are the classes for that .jar (doesn't work the imports upper).
I tryed copy the .jar file to same directory where are the classes. Doesn't help.
What should I do to add the .jar file correctly?
Command line
java
command don't know where to look for the miglayout jar file. You should run in from command line likePretty old question, but for the sake of completeness:
You need both
.
(current directory) andmiglayout-4.0.jar
to be on your classpath. You have two ways to do so. The easiest is to use -cpIn your case, you'll need to run:
or if you work on a Windows OS:
If unsure if you need to use a
;
(colon) or a:
(or whatever the OS is asking for), you can take a look atjava.io.File.pathSeparator
which contains the correct separator.The other way would be to change your CLASSPATH variable.