I am trying to make a simple JAR file using a simple GUI and a bound class, and another class. My question is this: when the project structure window asks for the "main class" and the "class path" does it want the source code name and path?

    1. When I enter the source (.java) name in the manifest properties, and the path
    2. to the class in the source filce, and I make the file, the jar won't launch because
    3. the Console says that the "class is not found".  Should I be entering another
    4. version of the class file containing the main routine?  "What about the path?
    5. Your help would be deeply appreciated.  Thank you very much in advance
    6. Christopher Lapp


Attachment(s):
ProjectStructureWindow.tiff
3 comments
Comment actions Permalink

'Class-path' attribute in manifest file is used when your JAR file depends on other JAR files located in the same directory. If all required classes
are packed inside the single JAR file you don't need to use 'class-path' attribute.

'Main-class' is a fully qualified dot-separated name of a class which will be used to start your application by 'java -jar your-jar-file.jar' command.
Note that you also need to pack *.class files into the JAR file. You can double-click on 'module-name compile output' elements in 'Available Elements'
tree to instruct IDEA to pack compiled class files into the JAR artifact.

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

'Class-path' attribute in manifest file is used when your JAR file depends on other JAR files located in the same directory. If all required classes
are packed inside the single JAR file you don't need to use 'class-path' attribute.

'Main-class' is a fully qualified dot-separated name of a class which will be used to start your application by 'java -jar your-jar-file.jar' command.
Note that you also need to pack *.class files into the JAR file. You can double-click on 'module-name compile output' elements in 'Available Elements'
tree to instruct IDEA to pack compiled class files into the JAR artifact.

--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


Thank you very much for your prompt and concise reply.   I'm a little confused by your second paragraph:

'Main-class' is a fully qualified dot-separated name of a class which will be used to start your application by 'java -jar your-jar-file.jar' command.
Note that you also need to pack *.class files into the JAR file. You can double-click on 'module-name compile output' elements in 'Available Elements'
tree to instruct IDEA to pack compiled class files into the JAR artifact.

When I double click on the "module-name compile output (see attachment)," I get a jar file of the entire module.   When I try to use a "fully qualified dot-separated name of >the module<  which is the output, the console (I'm using a Macintosh) says "class not found". )  Obviously the module.jar is not the
"main class" that the program is looking for.  If I try to use the fully-qualified dot-separated name of the source .java class (RandomStringForm.java) which is bound to RandomStringForm.form, the program also says "class not found."  I'm at an impasse, and I would deeply appreciate your clarification on this point.  Thank you very much for your time and trouble on this issue.



Attachment(s):
Questions.tiff
0
Comment actions Permalink

I played with it until I got it to work.  Thank you very much for  your kind assistance!
Your instructions were quite accurate, and it is a simple thing to do!
yours,
Christopher Lapp

0

Please sign in to leave a comment.