Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

17. Package, Jars and Deployment: Releas... > Making an executable JAR with packag...

Making an executable JAR with packages

image with no caption

When your class is in a package, the package directory structure must be inside the JAR! You can’t just pop your classes in the JAR the way we did pre-packages. And you must be sure that you don’t include any other directories above your package. The first directory of your package (usually com) must be the first directory within the JAR! If you were to accidentally include the directory above the package (e.g. the “classes” directory), the JAR wouldn’t work correctly.

Making an executable JAR

  1. Make sure all of your class files are within the correct package structure, under the classes directory.

    image with no caption
  2. Create a manifest.txt file that states which class has the main() method, and be sure to use the fully-qualified class name!


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint