r/javahelp • u/leifk3 • Jul 20 '21
Solved Can't create executable jar file
Hey guys,
i use Bluej for programming java (it's for school) and we made a little project with JFrames, etc... I didn't want to open bluej everytime just to start the program so I wanted to export it to a .jar file.
BlueJ includes this feature so I only have to say which is the class with the main-method and if I want to download the java libraries too.
That's fine but if I now open the Jar file there's just this error:
"error a jni error has occurred please check your installation and try again"
this is my class with the main-method: (is there my mistake?)
public class Simulation
{
private Controller controller;
private Login_Model lm;
private Game_Model gm;
public static void main(String[] args) {
new Simulation();
}
public Simulation() {
lm = new Login_Model();
gm = new Game_Model();
controller = new Controller(lm, gm);
}
}
0
Upvotes
0
u/johnmc325 Jul 20 '21
This does not sound like there is any problem with your code rather the problem is with different versions of Java. When you compiled java in BlueJ you will have used a version of Java. Now you are trying to run the JAR file outside BlueJ it will look on the machine for a version of Java and this may well be different. Go to a command prompt and type "java -version" to see what you get. Now check in BlueJ what version you are using to build your project. Getting them the same will help. See if that moves you forward.