Advertisement

05.01.2007 at 01:35AM PDT, ID: 22544372
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

NetBeans and Ant: Building second jar file based on subset of source

Tags: netbeans, jar, file, ant
I'm using NetBeans IDE v5.5 to compile a collection of sources into an executable .jar file.

What I'm trying to do is get NetBeans to automatically build a second .jar (ccd.jar) based on a subset (*1) of my code, everything except the aqm folder, which compiles in all the external libraries (*2), to produce a single .jar solely dependent upon the JRE.  I've included a file structure appendix below.

[Parts]
*1 Subset
The code is common between both jars except that:
aqm.jar includes all the source files and its Main class is apecc.qm.aqm.App
ccd.jar includes all sources except the aqm folder (see file structure below) and its Main clas is apecc.qm.ccd.App

*2 External libraries
aqm.jar works in an environment where it has access to the external libraries, so the current jar building process leaves them as external references.
ccd.jar needs to build those external libraries into itself, to produce a single unified jar with no external references (except the JRE obviously).
As I understand it, Jar (the tool, not the file) can't build jar files that recursively include other jar files, so I think I need to flatten the external libraries to include them in ccd.jar

[Existing files]
Here are links to my current Ant files within NetBeans:

http://www.lightenna.com/sitefiles/lightenna.com/build.xml
http://www.lightenna.com/sitefiles/lightenna.com/build-impl.xml
http://www.lightenna.com/sitefiles/lightenna.com/project.xml

They currently compile the sources and produce a single .jar file ( aqm.jar) which contains all my code, leaving a dozen or so libraries as external references.

[File structure]
My code
build
+ classes
   + apecc
     + qm
       + aqm (included in aqm.jar, excluded from ccd.jar)
       + ccd
       + core
       + geo
       + hub
       + qed
       + rep
       + test
   + com (directory containing a hierarchy of library .classes compiled from
source - "Internal libs")
   - log4j.properties

External libs (left as external references for aqm.jar, compiled into
ccd.jar)
+ dist
   + lib
      - J2PrinterWorks.jar
      - TrayIcon.jar
      - activation.jar
      - beandt.jar
      - commons-collections-3.1.jar
      - commons-configuration-1.2.jar
      - commons-email-1.0.jar
      - commons-lang-2.1.jar
      - commons-logging.jar
      - commons-pool-1.3.jar
      - concurrent.jar
      - dbswing.jar
      - dx.jar
      - jai_codec.jar
      - jai_core.jar
      - jakarta-oro-2.0.8.jar
      - jbcl.jar
      - jdom.jar
      - junit-3.8.1.jar
      - log4j-1.2.9.jar
      - mail.jar
      - mysql-connector-java-3.1.12-bin.jar
      - openmap.jar

Any questions please let me know.
Cheers, Alex
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: alexecho
Solution Provided By: CEHJ
Participating Experts: 2
Solution Grade: B
Views: 86
Translate:
Loading Advertisement...
05.01.2007 at 01:37AM PDT, ID: 19006702

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 01:44AM PDT, ID: 19006730

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 02:27AM PDT, ID: 19006850

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 03:33AM PDT, ID: 19007018

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 03:35AM PDT, ID: 19007022

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 03:40AM PDT, ID: 19007038

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 04:12AM PDT, ID: 19007156

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 04:17AM PDT, ID: 19007178

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2007 at 09:39AM PDT, ID: 19009727

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.01.2007 at 01:37AM PDT, ID: 19006702

Rank: Genius

>>so I think I need to flatten the external libraries to include them in ccd.jar

Just include them as a zipfileset
 
05.01.2007 at 01:44AM PDT, ID: 19006730

Rank: Genius

you can (and should) avoid adding your external jars to your application jar.
instead just add them to archive tag in your html.
much simpler to manage and will greatly improve startup times.
 
05.01.2007 at 02:27AM PDT, ID: 19006850

Rank: Genius

Accepted Solution
 
05.01.2007 at 03:33AM PDT, ID: 19007018
Thanks guys,
Based on CEHJ suggestion I've written this addition to my build.xml:

        <jar destfile="dist/ccd.jar" compress="true">
              <manifest>
                   <attribute name="Main-Class" value="apecc.qm.ccd.App"/>
              </manifest>
              <fileset dir="build/classes" includes="apecc/qm/ccd/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/core/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/geo/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/hub/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/qed/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/rep/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/test/**/*.*"/>
              <fileset dir="build/classes" includes="apecc/qm/ccd/**/*.*"/>
              <fileset dir="build/classes" includes="com/**/*.*"/>
              <fileset dir="build/classes" includes="log4j.properties"/>              
              <zipfileset src="dist/lib/activation.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/beandt.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-collections-3.1.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-configuration-1.2.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-email-1.0.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-lang-2.1.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-logging.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/commons-pool-1.3.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/concurrent.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/dbswing.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/dx.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/J2PrinterWorks.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/jai_codec.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/jai_core.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/jakarta-oro-2.0.8.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/jbcl.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/jdom.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/junit-3.8.1.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/log4j-1.2.9.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/mail.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/mysql-connector-java-3.1.12-bin.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/openmap.jar" includes="**/*.class" />
              <zipfileset src="dist/lib/TrayIcon.jar" includes="**/*.class" />
         </jar>

It outputs a ccd.jar, but I'm just looking at some other errors (which may not be related).  I'll report in as soon as I work out what's going wrong and accept the solution.  Thanks for your time.
 
05.01.2007 at 03:35AM PDT, ID: 19007022

Rank: Genius

your users are going to hate updates :)
apps are meant to broken into lots of jars for a reason.
 
05.01.2007 at 03:40AM PDT, ID: 19007038

Rank: Genius

just noticed its an app, not an applet.
In which case you can leave all the jars seperate and just include their names in the manifest.
That way you don't need to distribute *all* the classes everytime you make a change.
You'll find it a lot easier to manager that way.

and if you have some reason for wanting to have one large jar then have a look at

http://one-jar.sourceforge.net/

avoids all the issues you can have with expanding the jars.
 
05.01.2007 at 04:12AM PDT, ID: 19007156
Hi objects,

I totally get your point and I agree, but you don't know the project background.  This is a project I inherited and the (single) ccd.jar is being wrapped up in a Windows installer and shipped on CD.  My priority at the moment is to get the process working as designed, then to make improvements (like including a lib directory and referencing it).

The reason I haven't done that already is actually a Windows limitation.  When I code the shortcut (which goes into the Start menu) it can only accommodate a limited number of characters (255 I think), which is enough to include a single jar in the classpath, but not enough to include 15 jars in the classpath.  The solution is to write a batch file, get the installer to copy the .bat and the shortcut to run the .bat, not java directly.  There are of course issues with that too (what if the files aren't installed in the default 'Program Files' directory.... problems problems problems... so I'm just dealing with one at a time ;-)

Cheers, Alex
 
05.01.2007 at 04:17AM PDT, ID: 19007178

Rank: Genius

> it can only accommodate a limited number of characters (255 I think), which is enough to include a single jar in the classpath, but not enough to include 15 jars in the classpath.

u don't need to include all jars in the classpath, you should either specify them  in the jars manifest
or specify the directory that contains them using -Djava.ext.dirs=...

http://today.java.net/pub/a/today/2005/04/26/extending.html

if you have to deliver a single jar then have a look at one-jar, at least saves all the jars being expanded.
Assisted Solution
 
05.01.2007 at 09:39AM PDT, ID: 19009727

Rank: Genius

:-)

>>at least saves all the jars being expanded.

The jars are NOT expanded
 
 
20080236-EE-VQP-29