Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9311505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:23:01+00:00 2026-06-19T01:23:01+00:00

I have a command line application which I need to reference from another jar

  • 0

I have a command line application which I need to reference from another jar file and what I don’t want to do is copy and paste the existing code into the project that contains the source files for the other application, since this approach will result in maintainability issues.

I have thought about doing the following:

  1. deploying 2 jar files; running the command line app as a Process (the problem with this approach is that I don’t want to deal with orphan processes).

  2. deploying 2 jar files; calling the main method of the command line app using reflection. (I’m not sure this is a good idea).

  3. Somehow referencing the project that contains the source code for the command line application, and write an ant file that copies the class files into the jar file for the other application.

Which of this approach makes most sense? if the answer is #3, how exactly do I need to set up the eclipse project and/or write the ant file such that the class files I need are included in the new jar file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:23:03+00:00Added an answer on June 19, 2026 at 1:23 am

    In my opinion, I am more inclined to Approach 1.

    Assume your command line application is Jar1 and the referenced 3rd party jar is JAR2. Just add JAR2 to classpath. That’s it. You can invoke all the desired classes from Jar1. Since it’s a command line application and you don’t want to deal with orphan process, the ideal way to handle with it is, you should handle it from your command line application to kill orphan process, similar to what you do from your finally block of try-catch.

    I am disoriented towards your Approach 2 as reflection is very discouraged/outdated as it gets very difficult to debug in case of any issues

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which is built from command line (ANT) using J2ME Polish.
I have written very very simple console application which supports some command line options.
More specifically, I have a multithreaded command line Java application which runs and collects
I have a C# command-line application that I need to run in windows and
I have a java application from which I need to delete and insert data
I have a windows command-line application which must be executed in Mac OSX Lion.
I have an application need to print a MS Word .docx file from the
I have a small command-line application written in C that acts as a wrapper/launcher
I have a console application that uses a number of command line switches to
I have a little experience developing small command-line applications with Python. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.