I’ve created the jar file
it works well when I enter
java -jar file.jar
I’ve created a simple C++ program
#include <cstdlib>
int main(void){
system("java -jar file.jar");
system("pause");
}
I take the exe file created by visual studio, and run it inside the directory where the jar file is
I get the following error though:
Exception in thread “main” java.lang.UnsupportedClassVersionError: Main: Unsupported major.minor version 51.0
at java.lang.classLoader.defineClass1
at …
…
Could not find the main class: Main. Program will exit
what am I doing wrong?
also, although my program has gui inside, I can’t just double click on the jar file and run the program, I need to use a command line..
Are you using a RUNNABLE jar? How are you creating your jar file? are you creating it through the command line, or are you using your IDE to export one? follow this link if you are creating it manually, otherwise make sure you are selecting Runnable jar when exporting from your IDE.