Problem after compiling an IDEA-project without IDEA

Hi!

I have written some code and after compiling it from inside IDEA everything works fine.

What I can´t do is compile and then run my code by using the command line. I get a NullPointerExeption when I try to start my compiled Application (the compilation works fine).
So compiling with and without IDEA must make a difference!? My Application includes a GUI.

Can anyone help??

Thanks a lot,
Oush

4 comments
Comment actions Permalink

if you used IDEA's form designer, you have to include forms_rt.jar

0
Comment actions Permalink

Yes, I used IDEA´s GUI-Designer.
form_rt.jar is already included in IDEA under
File>Settings>Path-->Libraries(Classpath).

Unfortunately my Problem stays the same: After compiling my code with javac in the command line I get a NullPointerExeption when I try to run the compiled Application :(

Or do you mean something different with "include"!?

Thanks!

0
Comment actions Permalink

I just realized that a missing forms_rt.jar isn't the problem (actually, it will be, eventually, but you haven't hit it just yet :).

There are two things you need to do in order to run IDEA generated GUI outside of IDEA:

1) Make sure you have fully functioning form classes.

When running GUI projects under IDEA, by default it will compile the forms into byte code and then setup you environment so that these classes are loaded automatically when the program starts. OTOH, when you run your program from a command prompt, IDEA isn't there to do its behind the scenes magic and you have to make sure that the form classes are ready and present. The easiest way to do this is to go into Project Setup->GUI Designer and change GUI generation from "binary class file" to "Java source code", then (re)build your project. This will generate the necessary source code. After that you should no longer getting the NullPointerException.

2) Make sure forms_rt.jar is loaded when you run the project

Once you do (1) you will either get a compiler error (if you went the source code generation route) or a ClassDefNofFoundException when you try to run your code (if you used binary files). This is because, once again, IDEA isn't there to properly set up the environment. As you have mentioned, forms_rt.jar file is included in your project inside the IDE, but when you run your code outside IDEA, you have to include the jar manually (i.e. make sure that it's part of the classpath)

0
Comment actions Permalink

1) Done
2) Done

Everything works now with and without IDEA.

Thanks a lot!!!

0

Please sign in to leave a comment.