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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:21:49+00:00 2026-05-16T02:21:49+00:00

Conceptually, what am I doing when I’m loading a new Jar? Is URLClassloader the

  • 0

Conceptually, what am I doing when I’m loading a new Jar? Is URLClassloader the only choice? How should I form those URLs to point to a subdirectory containing more jars.

If anyone is feeling super-generous, some demonstration code to do the following would be really helpful (let’s assume “jars/A.jar” contains “myClass” which we want to instantiate):

  1. load some jar from a subdirectory
  2. return a particular class from it
  3. instantiate that class
  • 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-16T02:21:50+00:00Added an answer on May 16, 2026 at 2:21 am

    Conceptually, what am I doing when I’m loading a new Jar?

    Conceptually, you are not loading a new JAR. Rather, you are defining a class loader which will load code and other resources from the JAR file on demand.

    Is URLClassloader the only choice?

    In theory, you could implement your own subclass of ClassLoader, but that’s not necessary for what you are trying to do.

    How should I form those URLs to point to a subdirectory containing more jars.

    This is the nub of your problem I think. The URLClassLoader constructors interpret the URL[] argument as follows:

    “Any URL that ends with a ‘/’ is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be downloaded and opened as needed.”

    In the first case of the quoted text above, the directory is assumed to be the root of tree containing resources to be loaded.

    But I gather you are trying to set up a class loader that will load from all JAR files in a given directory. To do that, you need to:

    1. Read the directory and build a list of the File objects for any JAR files.
    2. Create an array to hold the same number of URL instances.
    3. For each JAR file File, use File.toURL() to create a URL and add to the array. (Using File.toURL() means that you will get kosher “file:” URLs for the JAR files that will work on your platform.)
    4. Create the URLClassLoader using the URL array.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing some initial research on a new project and one of my requirements is
I'm finally starting out with unit testing, having known that I should be doing
Conceptually speaking how would one go about writing an achievement system for a website
Redis is conceptually different from traditional SQL databases that I use, and I'm trying
I am wondering conceptually how load-balancing works on the EJB-level (not web session replication)
My problem is conceptually similar to solving anagrams, except I can't just use a
I'm having trouble understanding OAuth2 conceptually. I've read about the whole handshake process a
This is a practical Domain Driven Design question: Conceptually, I think I get Aggregate
I have a number of classes that are all related conceptually, but some more-so
The situation is, I once placed some conceptually related codes into one package in

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.