java - Can "Export to JAR in Eclipse" be as smart as javac? -



java - Can "Export to JAR in Eclipse" be as smart as javac? -

i want export part of java project jar file while including class files necessary run main class. project contains other main classes similar not identical dependencies. can run custom script accomplish it, this:

mkdir temp cd temp javac -sourcepath "../" -d . ../mainclass_a.java jar cmf mainclass_a.manifest ../mainclass_a.jar *

for elegance , more share others i'd run straight eclipse instead of custom script. however, when export jar file, or runnable jar file, every class file in project included. know can set manual filters exclude files, seems there should smarter option. how can configure eclipse include class files main class depends on?

i think want impossible in general case. yes, theoretically javac can find (and finds) dependencies between classes. right if these dependencies hard coded within project, i.e. not utilize dynamic class loading , reflection either straight or indirectly.

real applications typically utilize various 3rd party libraries, frameworks etc. so, dynamic class loading used if never in own code class.forname(). think if need such kind of optimization have write custom script builds custom jar. btw fact need gives tip projects organized incorrectly. should separate project 2 or more. each 1 should contain dependencies. in case can utilize built in eclipse ability bundle jar files.

java eclipse jar javac

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -