Intellij executes but java cant??
I am currently using 1.8.0 with intellij and it executes fine. But when i try to compile the exact same source code with "java" command line
i am currently trying to seek help on a java related problem but it seems something funny is going on. My question is located here...
http://www.javaprogrammingforums.com/whats-wrong-my-code/40979-issue-sending-value-new-pane-2.html
Source files can be downloaded at https://mega.nz/#!4FgQBABS!520OwtgJ0z_t6AeW3XbS9xAd1R-LllK01uIbLWBoPhE
with javac it compiles fine, but when i execute i get this error with MainPage
C:\Users\Syn\Desktop\testing\src>java MainPage
Exception in thread "main" java.awt.IllegalComponentStateException: contentPane
cannot be set to null.
at javax.swing.JRootPane.setContentPane(JRootPane.java:621)
at javax.swing.JDialog.setContentPane(JDialog.java:1047)
at MainPage.<init>(MainPage.java:19)
at MainPage.main(MainPage.java:36)
Please sign in to leave a comment.
When using designer .forms and you build the project by IDE it instruments the source code when binding java source class to a designer form. This code is not present in the .java file. To see what actually is generated enabled generation of GUI form into the source code rather than binary classes:
This is the error i got after trying to compile with javac. I have switched to java source code in editor > GUI designer.
The forms_rt.jar from IDE_HOME/lib directory must be added to the classpath.
i dropped forms_rt.jar in the same folder with all the .java files but im still getting the same error.
i checked the errors in intellij...
[code]
[/code]
intellij is in red..
>i dropped forms_rt.jar in the same folder with all the .java files but im still getting the same error.
This will not add it to the classpath. To add the jar to the classpath when you compile from command line use "-cp" javac option, see https://stackoverflow.com/a/2096298/2000323
ok so working from the same directory as in the picture above, i tried entering the command
"javac MainPage.java -cp forms_rt.jar"
and im getting compile errors...
[code]
C:\Users\Syn\Desktop\testing\src>javac MainPage.java -cp forms_rt.jar
MainPage.java:23: error: cannot find symbol
Index zero = new Index();
^
symbol: class Index
location: class MainPage
MainPage.java:23: error: cannot find symbol
Index zero = new Index();
^
symbol: class Index
location: class MainPage
MainPage.java:27: error: cannot find symbol
Index2 one = new Index2();
^
symbol: class Index2
location: class MainPage
MainPage.java:27: error: cannot find symbol
Index2 one = new Index2();
^
symbol: class Index2
location: class MainPage
4 errors
[/code]
>"javac MainPage.java -cp forms_rt.jar"
When you use -cp option you must list all the jars and directories for it. Here you missed the current directory, which can be referenced via "." Use this command:
"javac MainPage.java -cp forms_rt.jar:." or "javac MainPage.java -cp forms_rt.jar;." (i.e. with ";" separator).
"javac MainPage.java -cp forms_rt.jar;." worked great. Ill be putting this on a brief hiatus until i can resolve my primary issue from the other forums.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000100984/comments/360000066210
@Andrey-Dernov
Sorry, but did you run your compiled source?
Cause I have errors like this when running my Java source.
I've enabled Java GUI source code build instead of Binary Class File.
>> java crm -cp forms_rt.jar
(this won't work either)
>> java crm
Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesigner/core/GridLayoutManager
at crm.$$$setupUI$$$(crm.java:55)
at crm.<init>(crm.java:43)
at crm.main(crm.java:27)
Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLayoutManager
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
But I don't know why having this problem.
What I'm trying to do is,
Compile and run Swing (GridLayout-intellij) without Intellij IDEA.
Just to build and execute with only java and javac.
I've succeed with build, but I cannot execute my swing application due to upper error.
Any solutions?
You need to make sure that forms_rt.jar is in the classpath when your run your app. Refer to the java command syntax.