-3

I have a jar file but i dont have any source ,I wanted to build the entire project from this jar which only have class files .Can anyone help me out!

  • 2
    Use decompiler! – Yati Sawhney Jun 01 '18 at 07:56
  • Use can't use it straight away! https://stackoverflow.com/questions/647116/how-to-decompile-a-whole-jar-file – Yati Sawhney Jun 01 '18 at 07:59
  • 1
    Maybe include what you did with decompiling, and tell us what went wrong. – Tim Biegeleisen Jun 01 '18 at 07:59
  • 1
    You can't. A decompiler doesn't give you the original source code and often doesn't work. – Erwin Bolwidt Jun 01 '18 at 08:00
  • Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 0 it giving this error – Surya Kiran Jun 01 '18 at 08:02
  • But i have that bean which it is telling – Surya Kiran Jun 01 '18 at 08:03
  • that Jar IS the project. what you want is to get the .java files, I assume? why? either you created it, and should have it somewhere, or someone else made it, and you can ask them for the code. – Stultuske Jun 01 '18 at 08:04
  • You are basically asking the question "How do you reverse engineer a Java project?" Where reverse engineering is an entire field. You don't even have a guarantee that it was written in Java, unless you know that for a fact. With obfuscation, your job could get very very difficult as you will need to learn JVM bytecode. – Ryan Leach Jun 01 '18 at 08:04
  • yea someone else made it ,we have only jar which works fyn .but we dont have souce code – Surya Kiran Jun 01 '18 at 08:06
  • Someone else made it, as in, You don't own the copyright? Or you do and it's lost? It's 2 very different scenario's. Depending on the size of the project and obfuscation, you are anywhere between "Totally screwed", or "Reasonably doable with a lot of time and effort" – Ryan Leach Jun 01 '18 at 08:11
  • Regardless, we don't have nearly enough information to help, How you are attempting to decompile it, how you are attempting to recompile it, what it's potential dependencies are, what level of obfuscation you are seeing etc. – Ryan Leach Jun 01 '18 at 08:12
  • It seems as if you are trying to do something illegal... – Guilherme Mussi Jun 01 '18 at 08:48

2 Answers2

0
jar {
    manifest {
        attributes "Main-Class": "com.baeldung.fatjar.Application"
    }

from {
    configurations.compile.collect { it.isDirectory() ? it : 
zipTree(it) }
      }
 }

In Gradle, you can override the jar function to include the dependency classes as well. Else Jar task takes care of putting all the classes in one jar.

vishu9219
  • 761
  • 6
  • 14
0

To import a project from a JAR file

  1. Start Eclipse and navigate to your workspace.

  2. Create a new project. The name of the project is not important to the import process.

  3. Expand the project name in Package Explorer and left-click on the src folder.

  4. Right-click on the src folder and select Import…

  5. In the Import dialog, expand General and select Archive File. Click Next.

  6. Browse for the JAR file that you want to import and click Open.

  7. Another Import dialog box opens and shows you what’s in your JAR file. Ideally, you should see one or more files with .java extensions. If you don’t, then the archive was not built correctly. Make sure that you are importing into the src folder of the project that you just created. Here is what my dialog looks like when I import the JAR file from the previous example into a project called ImportTest: https://www.albany.edu/faculty/jmower/geog/gog692/ImportExportJARFiles.htm

Sonam sharma
  • 13
  • 1
  • 7