[java] how to open a jar file in Eclipse

I downloaded a demo jar file, and would like to open it in eclipse. What I did is

import->Existing projects into workspace ->select archive file

However, the eclipse returns "No projects are found to import".

As command line, I type

java -jar projectDemo.jar

This jar file just functions well. So it seems to me that jar file itself is OK, but how can I open it in Eclipse and modify this demo code? Thanks.

This question is related to java eclipse

The answer is


Since the jar file 'executes' then it contains compiled java files known as .class files. You cannot import it to eclipse and modify the code. You should ask the supplier of the "demo" for the "source code". (or check the page you got the demo from for the source code)

Unless, you want to decompile the .class files and import to Eclipse. That may not be the case for starters.


The jar file is just an executable java program. If you want to modify the code, you have to open the .java files.


there is an Eclipse app called Import Jar As Project. I think it is quite simple and useful. https://marketplace.eclipse.org/content/import-jar-project?mpc=true&mpc_state=


use java decompiler. http://jd.benow.ca/. you can open the jar files.

Thanks, Manirathinam.


Try JadClipse.It will open all your .class file. Add library to your project and when you try to open any object declared in the lib file it will open just like your .java file.

In eclipse->help-> marketplace -> go to popular tab. There you can find plugins for the same.

Update: For those who are unable to find above plug-in, try downloading this: https://github.com/java-decompiler/jd-eclipse/releases/download/v1.0.0/jd-eclipse-site-1.0.0-RC2.zip

Then import it into Eclipse.

If you have issues importing above plug-in, refer: How to install plugin for Eclipse from .zip


Firstly, it's necessary to know what is a jar file.

From Oracle,

JAR (Java Archive) is a platform-independent file format that aggregates many files into one. Multiple Java applets and their requisite components (.class files, images and sounds) can be bundled in a JAR file and subsequently downloaded to a browser in a single HTTP transaction, greatly improving the download speed. The JAR format also supports compression, which reduces the file size, further improving the download time.

As you can see,

  1. It has nothing to do with a Eclipse project. An Eclipse project can be a Java project, C++ project and so on. It's just a self contain project that can be recognized and operated as an unit by Eclipse.
  2. The .class files are generally the main part of a jar file. It's impossible to view the source code(.java file) unless you decompile the executable file(.class file) by some tools. Take Eclipse for example, you can choose the plugin Eclipse Class Decompiler as the tool.

A project is not exactly the same thing as an executable jar file.

For starters, a project generally contains source code, while an executable jar file generally doesn't. Again, generally speaking, you need to export an Eclipse project to obtain a file suitable for importing.