I have a very simple Programm that doesnt have any Frontend or GUI parts. It works just via user input in the console. I wanna build it so i can run it as an application on my PC without having to open my IDE. I want to send it to friends so they just have to open the Programm and it would work.
Asked
Active
Viewed 29 times
0
-
[Running JAR-Packaged Software](https://docs.oracle.com/javase/tutorial/deployment/jar/run.html) and [Working with Manifest Files: The Basics](https://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html) and [How to make an executable JAR file?](https://stackoverflow.com/questions/5258159/how-to-make-an-executable-jar-file), but any decent IDE should be able to help build the JAR – MadProgrammer Dec 23 '21 at 23:14
-
If you want in to be stand-alone without the need for java to be pre-installed, then you'll need to package your application into an exe file for windows that contains a packaged jar, and there is a different process for OSX and Linux. – sorifiend Dec 23 '21 at 23:16
-
Well I got a .jar file now. But the problem is that when i try to open the Program, nothing happens. As I said i have no GUI or anything in my Program. You can only controll it via the Console with the Scanner package. So can i somehow export a file that when opened shows a Window, like the Console window in Eclipse, in which you could write and get some user input aswell as output. – Cornelius Münch Dec 23 '21 at 23:50
-
How are you trying to "open" it? Double click on Windows? The standard way to **run** a Java program that has been exported as an executable JAR is `java -jar
`. – Stephen C Dec 24 '21 at 00:21 -
If you want to configure your system so that it will run a JAR file when you double-click it, see https://stackoverflow.com/questions/394616, https://stackoverflow.com/questions/8511063 etcetera. You will also need to explain to your friends how to do this, and how to install Java on their systems. – Stephen C Dec 24 '21 at 00:25
-
Another approach would be to use the Java 9+ `jpackage` command that will create a self-contained executable with an embedded JRE. But I don't think Eclipse supports this directly. You need to run `jpackage` from the command prompt, or from a Maven / Gradle build. And the resulting executable will be *platform specific*. – Stephen C Dec 24 '21 at 00:35
-
when I try to run it with "java -jar
" it just says "Error: Unable to access jarfile – Cornelius Münch Dec 25 '21 at 00:49. I will try to use the double click method.