Reputation: 67273
I want to create a jar file of a Java project, which compiles. I've looked on the internet but all the examples of how to do this seem to take one java file and work on that. I want to jar the root of the java project. How is this possible?
Thanks
Upvotes: 0
Views: 266
Reputation: 61793
According to this Stackoverflow topic you can built jar file using
You didn't specify your IDEA version. Before 9.0 use Build | Build Jars, in IDEA 9.0 use Project Structure | Artifacts.
You should learn to use a build tool like maven. You then could use the maven assembly plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>attached</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>*******your main class******</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
Or you could use ant(2) to create a jar file.
Upvotes: 1
Reputation: 103145
The jar command takes either files or directories. So you can simply specify the name of the directory that you want to jar rather than a file name. Once you know the command to jar a single file then you can jar a directory. More details here.
And this tutorial shows an example of jaring a file and a number of directories together.
Upvotes: 0