I have a Java project consisting of 5 Files, I need the program to run on another machine that only supports Java 8. How can I let InteliJ compile a .jar File that I can execute on the other machine? I'm also fine with using CMD commands.
I already tried changing the project SDK to the same I have on the other machine.
CodePudding user response:
In theory, the only thing you have to do is configure the language level of the project to Java 8 under File > Project Structure > Project (and verify that the language level of the module(s) follows the project settings, by being set to "Project default"), and then recompile.
However, if your project uses additional libraries, you need to ensure that they are also compatible with Java 8. Setting a Java 8 as the SDK of your project is not strictly necessary (the newest Java versions can still compile to Java 8 bytecode), but does help ensure that you're not using APIs defined in newer versions of Java, and when testing makes sure the libraries you're using are indeed Java 8 compatible.