0

The picture below is what my directory looks like: enter image description here

I'm trying to create an executable jar file for my javafx application StreamingJar.java and I'm getting very frustrated. I created a manifest folder and entered the following line into it: Main-Class: StreamingJar I then went into the command prompt and entered the following statement: jar cfm Streaming.jar manifest.txt *.class

It creates the executable jar file with no problems however when I double click on it nothing happens. When I try to open it through the command prompt I get the following error: java -jar Streaming.jar no main manifest attribute, in Streaming.jar.

I'm confused as to why there is no main manifest attribute in my jar file when I clearly included the manifest file. Can somebody tell me what I'm doing wrong?

Ryan Foster
  • 103
  • 7
  • Trying to do this manually. Use maven or ant. To figure out exactly what is wrong, open the jar file with any zip utility (or use `jar xvvf StreamingJar.jar` in a temp folder) and make certain it has [`META-INF/MANIFEST.MF`](https://docs.oracle.com/javase/tutorial/deployment/jar/defman.html) and the contents are correct. Also, what version of Java are you targeting? Because there are significant changes in Java 9 (basically, executable jar files are obsolete). – Elliott Frisch Apr 22 '20 at 01:06
  • I have java 12 on my machine. My program doesn't have any targeted java version. What do you mean by executable jar files are obsolete in Java 9, what happened? What is used instead? – Ryan Foster Apr 22 '20 at 01:15
  • 1
    Java 9 introduced the module system (along with `jlink`). Java 11 removed the JRE. You are supposed to create a custom runtime with `jlink` (and now in Java 14 `jpackage`) to distribute and for users to execute your application (take particular note of Oracle's new licensing terms as well). There are JREs available from some of the OpenJDK distributions. So you can potentially use that. But I felt like you probably didn't realize things have changed. – Elliott Frisch Apr 22 '20 at 01:20
  • So if I want to create an executable jar and I have java 12 on my machine, will I not be able to? Is there a way I can still do this? – Ryan Foster Apr 22 '20 at 01:27
  • Some related background reading [here](https://stackoverflow.com/questions/53111921/how-to-get-java-11-run-time-environment-working-since-there-is-no-more-jre-11-fo) and [here](https://stackoverflow.com/questions/52431764/difference-between-openjdk-and-adoptopenjdk). – andrewjames Apr 22 '20 at 01:48
  • Oracle supported Java 12 for six months ending in September 2019 under very different licensing terms than you probably realized. **And**, they've changed Java to make it produce custom executables (instead of executable jars). **But**, Java is open source so there are many possible ways to do something. **Also**, there wasn't just one "java 12". Which makes your questions very difficult to answer definitively. For example, `sdk ls java | grep 12` shows me options to install Java 12 with j9 or hotspot from adoptOpenJDK, or builds from Azul, Bell-SW and SAP (as well as one from "java.net"). – Elliott Frisch Apr 22 '20 at 02:39

0 Answers0