For AI agents: a documentation index is available at https://idratherbewriting.com/llms.txt. Markdown versions of all pages are available by appending .md to any page URL.

Search results

Java: JAR file

JAR is like Zip but for Java files. A JAR file simply contains a bunch of Java files and resources.

Extract a JAR

Open Terminal and type this, changing sample.jar to your jar file’s name:

xf sample.jar

Export to JAR

In Eclipse, got to File > Export > Java > Jar.

If you’re trying to share source files, include the following option in the export settings: “Export Java source files and resources”.

If you’re exporting your code for someone to use, just export the class files.

Adding a JAR file directly in Eclipse

If you receive a JAR file from someone, you can add the JAR file directly into your Eclipse project. Eclipse will then give you access to the classes without requiring you to extract them from the JAR.

Here’s how you add the JAR to a project in Eclipse. After you create a Java project, create a new folder by going to File > New > Folder. Call it “lib”. Then import the JAR file into the lib folder by going to File > Import > General > File. Alternatively, you could just copy the JAR file manually into that folder by navigating to it in your workspace.

Sponsored

You then need to add the JAR to your class path, which you can do by right-clicking the lib folder and choosing Build Path > Add to Build Path. Alternatively, you can add the JAR file to your project by right-clicking your project and selecting Properties. In the dialog box, select Java Build Path, then click the Libraries tab, and then click Add JARs and browse to the JAR.

For details, see section 25 in the Vogella Eclipse IDE Tutorial.

About Tom Johnson

Tom Johnson

I'm an API technical writer based in the Seattle area. On this blog, I write about topics related to technical writing and communication — such as software documentation, API documentation, AI, information architecture, content strategy, writing processes, agent skills, tech comm careers, and more. Check out my AI courses for more on the latest in AI and tech comm. If you're looking for info about documenting APIs, see my API documentation course.

If you're a technical writer and want to keep on top of the latest trends in tech comm, be sure to subscribe to email updates below. You can also learn more about me or contact me.

Finally, I want to note a couple of things. I usually write the first drafts of my posts myself and then use AI to improve accuracy, clarity, and detail in places, so my writing is a mix of human and AI. (Hopefully that's not too off-putting.) Also, the opinions I express on my blog are my own perspectives, not those of my employer.