Jump to content

Run jar file

stefanmz
Go to solution Solved by Eigenvektor,

The first question would be: Do you have Java installed (in the correct version)? IntelliJ comes bundled with Java, so it'll be able to run Java programs. However that bundled JDK isn't available to the OS as such.

 

Can you post the exact message(s) you get when you try to run "java -jar example.jar"?

 

Current IntelliJ should be bundled with Java 11. Do you have Java 11 installed in macOS? What happens if you enter "java --version" on the terminal? You should be able to install Java 11 with brew, if needed.

 

The other question would be: How did you create the .jar-file? If you're using e.g. Gradle to build. there are certain settings you need to create a runnable jar. You'll normally want to create a "fat jar", which includes all dependencies, so it can run on any machine without needing to install its dependencies first.

Hey so I made a jar file from my application in IntelliJ but it runs from IntelliJ so it works but when I double click on the file itself in finder it should run but it says it cannot be started and check console for error messages or something. If I do java -jar example.jar from the terminal it says the file cannot be opened. Why is that? Can I run jar files on Mac directly without IDE? It works just doesn't open directly on the Mac 

 

Link to comment
Share on other sites

Link to post
Share on other sites

The first question would be: Do you have Java installed (in the correct version)? IntelliJ comes bundled with Java, so it'll be able to run Java programs. However that bundled JDK isn't available to the OS as such.

 

Can you post the exact message(s) you get when you try to run "java -jar example.jar"?

 

Current IntelliJ should be bundled with Java 11. Do you have Java 11 installed in macOS? What happens if you enter "java --version" on the terminal? You should be able to install Java 11 with brew, if needed.

 

The other question would be: How did you create the .jar-file? If you're using e.g. Gradle to build. there are certain settings you need to create a runnable jar. You'll normally want to create a "fat jar", which includes all dependencies, so it can run on any machine without needing to install its dependencies first.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, Eigenvektor said:

The first question would be: Do you have Java installed (in the correct version)? IntelliJ comes bundled with Java, so it'll be able to run Java programs. However that bundled JDK isn't available to the OS as such.

 

Can you post the exact message(s) you get when you try to run "java -jar example.jar"?

 

Current IntelliJ should be bundled with Java 11. Do you have Java 11 installed in macOS? What happens if you enter "java --version" on the terminal? You should be able to install Java 11 with brew, if needed.

 

The other question would be: How did you create the .jar-file? If you're using e.g. Gradle to build. there are certain settings you need to create a runnable jar. You'll normally want to create a "fat jar", which includes all dependencies, so it can run on any machine without needing to install its dependencies first.

yeah it doesn't matter I will run it through IntelliJ then. I don't have Java and I don't want to download it, especially using brew because I don't want package managers. if it's available through Oracle for Mac maybe. But I will just use the jar to share the app with people so they can open it and I can run it through IntelliJ.

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, stefanmz said:

yeah it doesn't matter I will run it through IntelliJ then. I don't have Java and I don't want to download it, especially using brew because I don't want package managers. if it's available through Oracle for Mac maybe. But I will just use the jar to share the app with people so they can open it and I can run it through IntelliJ.

I'd recommend to use OpenJDK rather than Oracle's. Oracle requires a license in most cases. How do you know the ,jar is working properly if you haven't tested it on your machine beforehand?

 

Also, what's wrong with using a package manager? Homebrew makes life so much easier when it comes to installing dev-dependencies. It's as easy as "brew install openjdk@11". Of course you can always install it manually: https://gist.github.com/douglarek/bbda8cc23a562cb5d5798717d57bc9e9

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×