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 6792451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:58:16+00:00 2026-05-26T17:58:16+00:00

This issue is related to running a Java program (jar) dependent on thirdparty jar

  • 0

This issue is related to running a Java program (jar) dependent on thirdparty jar library even after setting classpath and trying so many other methods by reading articles in Internet.

I want to use a thirdparty Pack1.jar (it is not a part of jvm) as dependency of my programme.
I do not know where the Pack1.jar file could be in the deployment machine and I want the deployer to specify the path for the thirdparty libraries

I have tried the following alternatives in vain

  1. Setting the java.class.path programatically

    String class_path = args[0];
    System.setProperty("java.class.path",class_path);
    

    Here I am assuming that deployer would supply the classpath as first argument while running the program

  2. Setting the CLASSPATH env_var to locate the thirdparty directory

  3. While running, using the classpath option

    java -classpath /path/to/Pack1.jar -jar Pack2.jar 
    

    I think this would not work because documentation says that classpath is ignored when program is run with “java -jar”

  4. Setting the java.ext.dirs programatically.

  5. Setting the java.library.path programatically.

I do not want to specify the Class-Path in manifest because that takes only relative path and I do not know where the thirdparty library would be kept in deployment machine

But I am unable to get the jar running.

How can I fix this problem any help please.

  • 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-05-26T17:58:16+00:00Added an answer on May 26, 2026 at 5:58 pm

    Go for option 3. Put both jars on the classpath like this:

    java -classpath '/path/to/Pack1.jar:/path/to/Pack2.jar' com.packagename.yourclassname
    

    Note, that this is for Linux. on Windows, you would separate classpath elements with semicolons:

    java -classpath "/path/to/Pack1.jar;/path/to/Pack2.jar" com.packagename.yourclassname
    

    http://en.wikipedia.org/wiki/Classpath_%28Java%29

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

Sidebar

Related Questions

We have an issue related to a Java application running under a (rather old)
This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get
This issue is somewhat related: Problem with Code Generated by XSD.EXE: Sequence of Elements
I am running into this issue of releasing an already released object but can't
I'm getting this error while running tomcat 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver'. I'm using a combination of
Ok, I have seen several questions related to this issue, and I have tried
Trying to set up one-way SSL with Weblogic 11g and running into an issue.
This issue came up when I got different records counts for what I thought
This issue is driving me mad. I have several tables defined, and CRUD stored
This issue has me baffled, it's affecting a single user (to my knowledge) and

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.