7

How can I export a .jar file with source (.java) in NetBeans?

Mogsdad
  • 40,814
  • 19
  • 140
  • 246

2 Answers2

9

As simple as:

      Right click your project  »  Properties  »  Build  »  Packaging

Verify that Exclude from Jar File filter does not include *.java files.
That's it!

Your generated jar will include source code.

Project Properties

jpfreire
  • 1,188
  • 14
  • 23
1

A JAR file is a Java Archive, and generally includes compiled .java files (classes) into a directory format based on packages.

Generally, you would want to provide your .java files (java source code) in a format other than a jar.

Netbeans provides the ability to export a Project from

File > Export Project > To ZIP.

This will export the netbeans project along with any source code.

By default, The jar file is generated when you build your project in Netbeans and can be found in your "dist" directory inside your netbeans project. The "Files" tab (Ctrl + 2) in netbeans shows you your project files. You can right click on the jar file and find it's exact location on your computer by selecting properties.

See this question for more information on exporting a jar from Netbeans: Export JAR with Netbeans

Community
  • 1
  • 1
Matt Jones
  • 395
  • 1
  • 11