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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:37:11+00:00 2026-05-24T05:37:11+00:00

So I am making a server, a lot like IRC, just to learn more,

  • 0

So I am making a server, a lot like IRC, just to learn more, and here’s my problem.

I have commands that each person can call depending on their rights, and each “command” has it’s own class all located in one directory. I load all the classes into a HashMap, and it all works great if I add NEW commands, but if I change an old one, nothing changes in it.

So how can I use a URLClassLoader to load classes without caching them?

Thanks for any help.

This is the code I’m using

ClassLoader loader = new URLClassLoader(scriptURLS);
        try {
            for(URL u : scriptURLS) {
                if(u == null) continue;
                String fileName = u.getFile();
                int beginIndex = fileName.indexOf("commands/") + 9;
                int endIndex = fileName.indexOf(".c");
                fileName = fileName.substring(beginIndex, endIndex);
                String name = fileName.toLowerCase();
        Class<Command> c = (Class<Command>) loader.loadClass("chat.commands."+fileName);

I realize it’s not the cleanest or the most efficient code out there, but it works.

  • 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-24T05:37:12+00:00Added an answer on May 24, 2026 at 5:37 am

    You should be very careful creating your own classloaders as you could quickly run out of PermGen space as a result of circular references in memory that prevent the Garbage Collector from reclaiming the space taken by previous loaders (that is something to be careful of if you decide to dump your ClassLoader and create a new one every time you need to reload commands). More information on how that occurs here:

    http://www.zeroturnaround.com/blog/rjc201/

    If you have not already, you should take a look at JRebel. There is a license fee, but I think it may solve your problem:

    http://www.zeroturnaround.com/jrebel/

    Also, the java HotSwap (used for the java debugging API) may have hooks to facilitate this hot-redeploy behavior you’re looking for (usually available in IDE environments).

    I don’t fully understand your use case to be honest (why do you have to load the Command classes at runtime, and why do you need the hot-deploy behavior).

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

Sidebar

Related Questions

I have a SQL Server that holds a lot of data. An application, running
I've just gotten my production site up and running. I have a lot more
I'm making server that make a tcp socket and work over port range, with
I'm making AJAX calls to a server that sometimes return unparseable JSON. The server
i've been making web app's and working with various server side language like php,
Just wondering about how to avoid Magic Strings in Querystrings? I have a lot
I'm making an application that draws a lot of widgets and tiles on a
I heard that minecraft server is very leaky, can consume a lot of resources
We currently have a Java applet that generates a lot of data and uploads
I would like to have a particular url structure of my company dev server.

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.