-1

Manifest.txt location: /Dropbox/workspace/commonDenom/bin Class location: /Dropbox/workspace/commonDenom/bin/commonDenom/ Class names:

commonDenom.class
UserInterface.class

Manifest.txt content (with two trailing blank lines):

Main-Class:  commonDenom.UserInterface
(blank line)
(blank line)

Then in terminal I perform the following:

cd /Dropbox/workspace/commonDenom/bin
jar cfm commondDenom.jar Mainfest.txt *
jar tf commonDenom.jar

The output is as follows:

META-INF/
META-INF/MANIFEST.MF
Manifest.txt
commonDenom/
commonDenom/.DS_Store
commonDenom/commonDenom.class
commonDenom/UserInterface.class

Why isn't commonDenom/UserInterface.class the first line if that's the one I've designated as the Main-Class in the manifest? Is something wrong with the syntax of Manifest.txt?

dbconfession
  • 1,147
  • 2
  • 23
  • 36
  • I don't understand the question. Do you expect the `jar` tool to read the manifest file for reordering the output and to put "more important stuff at the start" when you use it to list the raw content of the archive? – Hauke Ingmar Schmidt Mar 08 '14 at 01:01

1 Answers1

0

Why isn't commonDenom/UserInterface.class the first line

Because it wasn't the first file encountered by * or specified in the -m option.

if that's the one I've designated as the Main-Class in the manifest?

Irrelevant. The Main-Class attribute doesn't control the order of the file. It controls what the JVM uses as the entry point when you use java -jar.

Is something wrong with the syntax of Manifest.txt?

No.

Why do you think it should be the first line? It doesn't need to be the first line. The MANIFEST.MF tells Java what the main class is, not the order in the JAR file.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I need UserInterface to be the entry point and creating the jar file in Eclipse isn't working. So I'm following instructions on how to create a jar manually. Whats the point of me putting Main-Class: commonDenom.UserInterface. If what you're saying is true (that the order of the classes when listing them doesn't matter, how can I confirm that it is using the class that I designated as the entry point? i.e. how do I check the MANIFEST.MF? – dbconfession Mar 08 '14 at 01:11
  • The entry point is whatever the `Main-Class` attribute says it is. That's *why* you have to specify `Main-Class:`, and that in turn is why the order doesn't matter. The JVM looks in the Manifest, not at the order of the JAR file. You can confirm that it is using your entry point by *running* it, which frankly you should have done already, some time ago, before even asking this question. What else would it use? – user207421 Mar 08 '14 at 01:17
  • To clarify, the Eclipse-created jar file won't run. So as I stated above, I'm following instructions to create the jar manually. I've done so and it still won't launch. I thought it had something to do with the entry point. For details please see this post. http://stackoverflow.com/questions/22211381/java-exporting-as-jar-has-errors?noredirect=1#comment33747115_22211381 – dbconfession Mar 08 '14 at 01:30