How to package Jar by copying ONLY USED classes from onother jar ?!
-
Hi all, I am just an amateur javac user, buidling occasionally some simple applications. Meaning i dont know much of programming generally. I will try to express my problem as quick and clearly. Here it is. I am using Netbeans. I have a 'jimakoskx' Project trying to have there all my succesful/interesting classes that occasionally i may write....in years. Like my library Project. Lets say i have there a 'mess' of 200 classes (library classes meaning some of them importing 'some of them' ..others may be independent etc) ---- Now lets say that a friend ask me a simple application. And because of my Library Project i am ready to finish this application by just a)Create a new Project b)Import the Library project (Properties->Libraries->add) .......(Copy dependencies because i want to give the 'client' the jar file ) c)easy write the new application ... My problem is NOT that i must give to client the FOLDER containing the application.jar and the library jar. Ok..even if there be some solution ...this is not what made me come here to ask. My problem and my question is the following. My application jar use lets say only 1 class of my library jar. But because the library jar lets say is 2 MB then i am distributing (for the application) 2 MB (by importing library) ...plus...some KB of the actual ('new') application. Now...if this is a big problem .....i can solve this either by manually copy the interesting classes from library to actual project either by ...(lets say i have nothing to do)...by creating a program that do it for me. And the question is ... Is there a way doing this in Netbeans ??? Thank in advance...
-
Hi all, I am just an amateur javac user, buidling occasionally some simple applications. Meaning i dont know much of programming generally. I will try to express my problem as quick and clearly. Here it is. I am using Netbeans. I have a 'jimakoskx' Project trying to have there all my succesful/interesting classes that occasionally i may write....in years. Like my library Project. Lets say i have there a 'mess' of 200 classes (library classes meaning some of them importing 'some of them' ..others may be independent etc) ---- Now lets say that a friend ask me a simple application. And because of my Library Project i am ready to finish this application by just a)Create a new Project b)Import the Library project (Properties->Libraries->add) .......(Copy dependencies because i want to give the 'client' the jar file ) c)easy write the new application ... My problem is NOT that i must give to client the FOLDER containing the application.jar and the library jar. Ok..even if there be some solution ...this is not what made me come here to ask. My problem and my question is the following. My application jar use lets say only 1 class of my library jar. But because the library jar lets say is 2 MB then i am distributing (for the application) 2 MB (by importing library) ...plus...some KB of the actual ('new') application. Now...if this is a big problem .....i can solve this either by manually copy the interesting classes from library to actual project either by ...(lets say i have nothing to do)...by creating a program that do it for me. And the question is ... Is there a way doing this in Netbeans ??? Thank in advance...
There is execution flow. And code references. Neither guarantees finding all code usage. Code is loaded dynamically in java. A class is not loaded until it is referenced. The byte codes contain that information though so it can be dynamically determined. But that doesn't mean it actually runs. Then a developer can write code that dynamically loads classes. Or they can use libraries that do that. So normally execution flow needs to be done to determine what runs. But, for example, what happen if there is a report that only runs on the first of the month and you use execution profiling on the 15th to find all the classes that are used. You will not find the classes used in that report. So it is manual process... You use profiling and attempt to execute your application. The profiled classes are the ones that are executed. Anything else isn't. Then build your jar(s) using only those and then completely test the application. If your tests are complete then it should work.