0

I have a .zip file that contains a package that holds the different source code files generated from http://www.jsonschema2pojo.org/.

I initially thought I'd be able to add the generated code (contained in .zip file) to my build path directly, however I discovered that I cannot work with .java files in my project, as importing the .zip file into my project shows the package path to be empty.

It turns out that I cannot use this .zip file because it is full of .java source files and it has no .class files.. which is why when I attempt to reference the file from my project, it says it can't resolve it to a type.

I know I can just go through the zip file, create the package and classes and copy/paste the source code, compile all of that, and then reference that in my program. However, there has to be an easier way than just doing all of this manually.

How do I convert a .zip file full of source into a .zip file full of class files directly referenceable from my Eclipse?

steelmonkey
  • 415
  • 2
  • 6
  • 19
  • How did you get the zip file? – sgpalit Aug 26 '15 at 06:46
  • The website mentioned above allows you to copy and paste a JSON object into a generator that will return the source code for a .java file that you can use to convert the JSON to Java objects. I pasted in the JSON from [here](https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%3D%22MSFT%22%20&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys) and clicked the "jar" button, and downloaded the link that popped up next to it. – steelmonkey Aug 26 '15 at 06:52
  • If you are using maven you can try to unzip with antrun-plugin, check this answer http://stackoverflow.com/questions/3264064/unpack-zip-in-zip-with-maven – sgpalit Aug 26 '15 at 07:00

1 Answers1

0

There is no easy way of achieving what you are looking for, I would recommend to write up a utility program which can take input as ZIP file, iterate the file list, read and create the package folder structure and copy the file to the location. Before executing this program, you have to create eclipse Java project so that the extracted files can be copied to the workspace. This way it functions properly when program generates the file and then you can extract this package in .jar file.