¿IntelliJ IDEA error? I can not compile anything [Solved]

Hi, I have been surprised that I can IntelliJ IDEA compile anything, I always make some mistake, even the simplest example I can do I mark it as a bug, I honestly do not know why this is the error, I tried the following code:

import javax.swing.*;


public class Principal{

    public static void main(String[] args){

        JPanel panel1 = new JPanel();
        JFrame aplicacion = new JFrame();

        aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        aplicacion.add(panel1);
        aplicacion.setSize(230,230);
        aplicacion.setVisible(true);
    }
}



And I marked the following errors:

"C:\Program Files\Java\jdk1.6.0_26\bin\java" -Didea.launcher.port=7536 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.6.0_26\jre\lib\alt-rt.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\alt-string.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\sunjce_provider.jar;C:\Users\Morringo\Documents\IntelliJ IDEA Projects\Example 1\out\test\Example 1;C:\Users\Morringo\Documents\IntelliJ IDEA Projects\Example 1\out\production\Example 1;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain MainClass
Exception in thread "main" java.lang.ClassNotFoundException: MainClass
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     at java.lang.Class.forName0(Native Method)
     at java.lang.Class.forName(Class.java:169)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)

Process finished with exit code 1


Using Windows 64-bit system and I think the example is pretty good. That kind of mistakes I started to make an overnight.

Thank's all.
Greetings.

2 comments
Comment actions Permalink

Your example class is called Principal, you are trying to run a class called MainClass. I assume you compiled it ?

0
Comment actions Permalink

Ok, thank's for your answer.
The error of this example was the setting. But in another example, also I get error, be that previously had tried and not come out any errors.


public class Principal{

    public static void main(String[] args){

        FrmPrincipal formulario = new FrmPrincipal(250,250,"Form");
        formulario.setVisible(true);
    }
}


import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FrmPrincipal extends JFrame{
    private JButton button1;
    private JPanel panel1;
    private JTextField textField1;
    private JFrame frame = new JFrame();
    private int width, height;


    public FrmPrincipal(int width, int height, String title) {

        this.width = width;
        this.height = height;
        frame = new JFrame();
        setTitle(title);



        button1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(null,"button1 =)");
            }
        });


    }

    @Override
    public void setVisible(boolean b) {
        frame.setContentPane(panel1);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.setSize(width, height);
          frame.setVisible(true);
          frame.setLocationRelativeTo(null);
    }

    @Override
    public void setTitle(String title) {
        frame.setTitle(title);
    }
}



Is a simple button that when the user clicked it, this button display a Dialog showing text: "button1 =)"
¿What's my error?

=== Added ===

I can't find the error, I have installed JDK 1.6 update 26 (64 bits) and configured in IntelliJ IDEA and I've make this basic example and the error appears too.

public class MyForm1 extends JFrame{
    private JButton button1;
    private JPanel panel1;
    private JTextField textField1;

    public static void main(String[] args) {
        JFrame frame = new JFrame("MyForm1");
        frame.setContentPane(new MyForm1().panel1);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

}


I only press Alt+Insert and select the option for the main method, the error for this last example is:

"C:\Program Files\Java\jdk1.6.0_26\bin\java" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.6.0_26\jre\lib\alt-rt.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\alt-string.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.6.0_26\jre\lib\ext\sunjce_provider.jar;C:\Users\Morringo\Documents\IntelliJ IDEA Projects\Example 1\out\production\Example 1;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain Principio.MyForm1
Exception in thread "main" java.lang.NoClassDefFoundError: com/jgoodies/forms/layout/FormLayout
     at Principio.MyForm1.$$$setupUI$$$(MyForm1.java)
     at Principio.MyForm1.<init>(MyForm1.java:13)
     at Principio.MyForm1.main(MyForm1.java:20)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: com.jgoodies.forms.layout.FormLayout
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     ... 8 more

Process finished with exit code 1


Please saying me, ¿what's my error?

0

Please sign in to leave a comment.