Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a single jar to include multiple java files from different folder

Tags:

How my project structure looks like

|---> src (folder)  
         |----> Repository (folder)  
         |----> util (folder)  
         |----> config (folder)   



|---> Repository (folder)
         |---> property file 1
         |---> property file 2
         |---> property file 3

Config folder has the same structure as Repository folder.

Util folder structure is

|---> util (folder)
         |---> Main class file
         |---> Sub main class file
         |---> common function file
         |---> Report file

Now my Main class file under util folder in the default file which fetches the data from the files under Repository and config folder. It also has a link which opens the Sub main class file and uses the common function as well as Report file under the util folder itself.

I am successfully able to run the code from Eclipse but now I need to create a jar file to perform these actions. I tried to create a jar file from command prompt as well as from Eclipse, it opens the Main class file UI but unable to fetches the data from other folder files or unable to open the sub main class file.

I am pretty new to this jar thing and don't know much about it.

Suggestions ?

like image 474
Naseem Avatar asked Aug 03 '16 07:08

Naseem


1 Answers

You can use the following command to build the jar and specify the main class entry point (Main).

jar cfe output.jar Main src/Repository/* src/util/*.class
like image 75
Nicolas Henneaux Avatar answered Nov 14 '22 21:11

Nicolas Henneaux