Pacnet
Pacnet

Reputation: 61

Combining multiple .java files into one .jar file (they are dependent of each other) in Eclipse

Here's the deal. I'm fairly new to Java and I have these three .java files that I need to compile into one .jar executable.

  1. ho.java
  2. read.java
  3. write.java

Each file has it's own JFrame and the thing is I need to make an action in ho.java open the JFrame in read.java and another action in ho.java open the JFrame of write.java.

In eclipse, how would I go about doing this? I've seen topics where people want to know how to combine multiple jar files into one, but I wonder how to compile multiple .java files into one .jar file.

If it's impossible, then how should I interconnect these three files?

Upvotes: 0

Views: 2577

Answers (3)

Ricardo
Ricardo

Reputation: 67

Put all your files in a folder in your Eclipse project and then:

  1. Right click in your folder
  2. Export
  3. Java -> Runnable JAR File

Upvotes: 0

nanofarad
nanofarad

Reputation: 41281

Simply, you can export them.

In the package explorer, select all of the necessary java files wit Ctrl+click, right-click the selection, and select "export"

enter image description here

Continue through the wizard, selecting Runnable Jar file or Jar File to your liking, select the export directory, and finish. You are done.

However, if you selected to export the ant buildfile, you can reuse it with a builder. Right-click your project, and select properties.

enter image description here

Under "builders", add a new builder as shown here:

enter image description here

Its type should be an ANT builder.

For the buildfile, select browse workspace or browse filesystem(depending on where you exported it) and select the .xml file you exported previously. You can now do Project->Build and your Ant build will occur as part of the build process.

Upvotes: 2

Devolus
Devolus

Reputation: 22084

If they are in the same project, then you can simply right click on your project in the popumenu select Export...

In the following Dialog you go to Java -> Runnable JAR File

Upvotes: 2

Related Questions