Newbie Question Compiling App

I have created a very simple test application to display Hello World in a form.  The code is as follows:

import javax.swing.*;

* Created by Ian on 4/30/14.
public class Test {
    private JPanel panel1;

    public static void main(String[] args) {
        JFrame frame = new JFrame("Test");
        frame.setContentPane(new Test().panel1);

the form is

hello world.tiff

This works fine in the IDE so I tried creating a jar file using an arcive in the project structure and then building it. The manifest file created looks like

Manifest-Version: 1.0
Class-Path: ./Test.jar
Main-Class: Test

The app will not run from my mac desktop or terminal program.  Getting a class not found message in the terminal

Can someone please point me in the right direction?


> Getting a class not found message in the terminal
And what is the name of not found class?



Error: Could not find or load main class test.jar


Thank you. Then I expect you start java with wrong option. Please try:
> java -jar test.jar

Please comment if more problems occur, they are still possible.


Getting the following error

Exception in thread "main" java.lang.NoClassDefFoundError: com/jgoodies/forms/layout/FormLayout
 at Test.$$$setupUI$$$(
 at Test.<init>(
 at Test.main(
Caused by: java.lang.ClassNotFoundException: com.jgoodies.forms.layout.FormLayout
 at Method)
 at java.lang.ClassLoader.loadClass(
 at sun.misc.Launcher$AppClassLoader.loadClass(
 at java.lang.ClassLoader.loadClass(

 ... 3 more

I think this means that it is not finding the JGoodies library.  Is that a claspath issue?

Yes, you need to add a jar with FormLayout (et all) to your classpath.



Okay.  Thanks so much for your help.

I come to Java and the IntelliJ IDE from the c++ world.  I am used to the IDE creating the basic makefile that if necessary registers the appropriate components.  i.e the equivalent of adding the classpath for you.  Inetliij does not do this for you?


Quite natural question. In Java there are several kinds of makefile analogs. There is a lot of information to read, I'll point just to basic directions to investigate.

1. For quick ad-hoc configuration you can check Project Structure dialog / Artifacts section, and configure a jar artifact. This is IDEA-specific, you can't (to my knowledge) use or automatically convert this artifact definition to other IDEs like Eclipse. It is probably Ok for small "hello-world" applications.

2. More universal solution is to use some popular third-party dependency management tool, independent from IDE, and use IDE integration with that tool.
This integration typically includes some actions to generate necessary tool-specific files, or import these files and build IDEA project from them.

2.1. Most popular tool is probably Maven:
And this is the docs on our integration with it:

2.2. Old tool is Ant:
But it is now considered obsolete.

2.3. There are also Groovy-based tools Gant and Gradle. I'm not very familiar with them. AFAIK, they are Ok nowadays, just less ubiquitous than Maven.



Thanks.  Trying Maven out. (Don't seem to be able to mark this thread as answered.)


Please sign in to leave a comment.