Import of excuting jar doesn't work in eclipse - java

I deleted my project permanently and I want to import my old executing .jar into eclipse.
Eclipse import function does not find anything it the jar file.
Can someone give me a tip or recover the file?
Here is a screenshot of eclipse
Thank you
Click here for the file to recover

You cannot recover the project. You did not set to export source files while exporting, there are only .class files.
For future reference select Export Java source file and resources while exporting the project.
Reference: http://www.albany.edu/faculty/jmower/geog/gog692/ImportExportJARFiles.htm

I am curious to know if it's jar why do you want to import as a project?
You can import external jar as a "APP Client Jar File" which is under Java EE.
I tried this with your attached jar and I am able to import it and able to see the content in it.

You are mixing a few things. If you deleted your project source you won't be able to recover it unless you decompile it, and it will be obfuscated even though.
What you have is the compiled project, resulting from taking your source (.java) and compiling it to .class files.
The Import option in Eclipse is made for importing .project files, that hold your project's information. Also you could create a new project from your existing code but as far as I know you just can't create/recover a project from it's compiled jar.

Related

Problem with source of my JAVA Project- Can not upload it to Eclipse

I have a basic but important question.
Our client has an application that has been written with JAVA. We need to modify something in one of the classes.
They passed us the Source files of this project, but I really have doubt that if they sent us the source or no!
This is the structure of zip file:
But when I import it to Eclipse (Import Existing Project to workspace) I see the error that is saying: "No projects are found to import"
How can I be sure if they sent us the source?
Actually I want to be sure and then ask them...
I tried also to open it with Apache Netbeans but it says "No Netbeans projects added".
Can anyone help me about this?
Thanks
Sep
The complete build structure does not look like a default gradle/maven or even Eclipse/Netbeans IDE style (as mentioned already by greg-449)
Howto import plain sources into Eclipse - without maven or gradle
Normally a eclipse project setup looks like
/.project
/.classpath
/src/java
Hello.java
/test/java
HelloTest.java
/bin
Hello.class
HelloTest.class
So I would do following
Create a new Java Project in eclipse and use as customized project location your root folder of your source files.
When asked for source folder location you can either use /src/java (when you
you are free to restructure the files), or add all folders where
sources are located (e.g.maybe nbproject contains sources ?) as source
folders of the project.
Libraries: If the project contains dependencies and you want no compile failures, you must add all libraries to your eclipse project. When you can start the (ant ?) build you will have all libraries inside build folder. Add those to your eclipse project at the build path properties.
After project creation + build in eclipse, the files .project and .classpath are created. Inside the project you should now see at least your sources inside java source folders - and maybe you are able to start the application.
For more information see also
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-3.htm
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-wizard-java-project.htm
Thanks everyone,
I did not found any .JAVA files in the source so I am sure that they did not pass me the complete source file!
Thanks
Sepide

how to add a jar file into intellij

I have a jar file which is a bunch of .class files(Java). I need to use some of the classes inside of the jar file into my intellij project. I followed these instructions:
Adding class/jar file to IntelliJ IDEA
The jar file did successfully link into the project as an external library. But, I am not able to access any of it's classes. Nor am I able to import any files from it. Can some one help me out ?

Importing JParsec in Eclipse

I downloaded both the .jar file and the "source and documentation" zip archive from the JParsec download section. Somehow I failed to import the JParsec source code using the Eclipse IDE (and also to find any documentation). Can someone please explain how to import it?
Thanks a lot!
You need to create a Java project and add the appropriate .jar file into the build path. You can also link the source file to the .jar file using the "Build Path" choice.
The codehaus project is no longer active, jparsec is now hosted on github. If you clone the source code from there, you can import the project using the maven plugin for Eclipse, or alternatively do mvm eclipse:eclipse inside the project source tree and then open the project in Eclipse.

Import project (jar) into Eclipse

I got a .jar file which I need to import into Eclipse. However, I don't want to have the jar as a referenced library. I need the .jar to be included like a "normal" project, with packages(!) and .java files.
I tried to do the following:
New Java project -> Import -> General -> Archive File. In this case, when I place this jar also as a referenced library, it is imported but with .class files.
New Java Project -> Import -> General -> File System. Imports the .java files, but the packages are lost and are normal folders. Also, the files are somehow strange, because the "j" in the icon looks differently, and errors are not noticed (no underlining)
Importing "Existing Projects into Workspace" doesn't work at all, it says that there is no project. I also tried to import the jar as a zip after extracting it, this gives me the -java files, but it destroys the packages.
Does anyone know how to import this correctly?
I have managed it this way:
New Java Project -> Java settings -> Source -> Link source (Source folder). There I added my decompiled jar and it was imported correctly :)
You can also create a new Java Project and then do File -> Import -> General -> Archive File. This will save you a step of unzipping your jar and adding as a linked source folder.
You cannot import a jar that way, unless it has the source code packed in the jar. If you really need the source code, you'll have to find an archive somewhere. But of course, not everyone is willing to share his source...
I tried the below and it worked.
Create a New Java Project
Goto File > Import > General > Archive File
Select the required Archive file(.jar in this case) from your local system.
Select the project you created in Step 1 and click Ok
This will save you a step of unzipping your jar but if there are .class files, eclipse won't convert them to .java files. This has to be done seperately.
Below helps in all recent eclipse.
Please try below eclipse plugin to import jar as project :
Step 1) Eclipse Help > Eclipse Marketplace
Step 2) Install the plugin "Import Jar As Project"
Step 3) Restart Eclipse
Step 4) File->Import->Other->Jar without source
Step 5) Select a jar/war file and click finish
New project will be created from the jar
https://marketplace.eclipse.org/content/import-jar-project
Thank You.

Can you import a non-archive project directory in Eclipse?

I read this article which shows how to import/export projects in Eclipse (although it seems a little outdated and I'm using 3.7 Indigo).
To export a project, you go to File >> Export and it creates some kind of "project archive" file on the local file system. You could then email it to someone else, who could then import the archive as a new project or into an existing project.
But what if you don't have an "archive" file to begin with?!? What if you just have the project files and directories but without all the Eclipse-metatdata (.project file, etc.)? Is there anyway to tell Eclipse to look at, say:
/home/myuser/some/path/to/project/root/
src/main/java
SomeObject.java
build.xml
...and get it to read that as a new Java project?
Try the steps below:
Create a Java Project in Eclipse as below:
Load the project contents from your file system as below:
Hope this works for you.
.project and .classpath files are the base of the project structure. Without a .project file Eclipse won't recognize your project. The .classpath is important too but that one changes between environments. Should you use the files from another environment you'll have to reconfigure some settings.
Rather than emailing code, I suggest you use a Version Control system and, also, some Eclipse plugins. SVN + Subclipse for example.
If you trully want to send the project to another person just send him the project's folder and import it as an existing project by doing right click on the project explorer and selecting Import > Existing Project into workspace.

Categories