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

  • Home
  • SEARCH
  • 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 8869095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:24:09+00:00 2026-06-14T17:24:09+00:00

I’m a seasoned programmed and I’ve come across this very strange problem that I

  • 0

I’m a seasoned programmed and I’ve come across this very strange problem that I haven’t been able to fix so far. I’m getting this error:

Exception in thread "Thread-0" java.lang.NoClassDefFoundError: rec/MiscIO
        at rec.RECTool.run(RECTool.java:264)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: rec.MiscIO
        at java.net.URLClassLoaderrun(Unknown Source)
        at java.net.URLClassLoaderrun(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more

Here is the relevant line:

File savedTo = MiscIO.copyJar(root);

What I dont understand is that this is a small application, and the classes in use are in the same package. Basically identically setup besides the class names and contents. However I specifically get the error with only some of my classes, not all. I use these lines before the error occours, and these are in the same package and everything.

Logger.log("Found new root: " + newRoots[i0]);
...
FileLocker locker = new FileLocker();
...
locker.lock(PathManager.getJar());

So three classes that are basically identical to the setup of the one with the error, and only one throws the exception. This makes no sense to me.

I have tried various arguments to run the jar including classpath modifications and calling the main class directly instead of using the jar command, to no avail, such as these:

java -jar <jarname>
java -cp . <jarname>
java -cp <jarname> -jar <jarname>
java -cp <jarname> <main class here>

However if I unpack the jar and run the program, the error doesn’t occur. I thought it might be some dependency of MiscIO failing to load or the static intializer failing to load, but both are absent in my code.

Also, I’m using Netbeans to generate the jar, and the manifest is set correctly. Here’s the entire code:

    package rec;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import java.net.URL;

/**
 * @author Colby
 */
public class MiscIO {

    public static void copyJar(RandomAccessFile out) throws IOException {
        URL jarSource = RECTool.class.getProtectionDomain().getCodeSource().getLocation();

        InputStream in = null;
        try {
            in = jarSource.openStream();
            copyToRAF(in, out);

        } finally {
            if (in != null) {
                in.close();
            }
        }
    }

    public static File copyJar(File saveJarTo) throws IOException {
        URL jarSource = RECTool.class.getProtectionDomain().getCodeSource().getLocation();
        saveJarTo = new File(saveJarTo, "classlist.jar");

        InputStream in = null;
        OutputStream out = null;
        try {
            in = jarSource.openStream();
            out = new FileOutputStream(saveJarTo);
            copyStream(in, out);

        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
        return saveJarTo;
    }

    public static void copyStream(InputStream in, OutputStream out) throws IOException {
        int len;
        byte[] data = new byte[1024 * 8];
        while ((len = in.read(data)) != -1) {
            out.write(data, 0, len);
        }
        out.flush();
    }

    public static void copyToRAF(InputStream in, RandomAccessFile raf) throws IOException {
        raf.seek(0L);

        int len;
        byte[] data = new byte[1024 * 8];
        while ((len = in.read(data)) != -1) {
            raf.write(data, 0, len);
        }
    }

    public static void copyFile(File from, File to) throws IOException {
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream(from);
            out = new FileOutputStream(to);
            copyStream(in, out);

        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }
}

On a last note, I thought it might be conflicting versions of Java installed in my machine, or x86/x64 conflict by some fluke, so I uninstalled all Java distributions and installed only the latest of one architecture and the problem remains.
Any of you guys seen something like this before?

  • 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-14T17:24:11+00:00Added an answer on June 14, 2026 at 5:24 pm

    Dude, what does your file locker do?

    1    FileLocker locker = new FileLocker();
    2    locker.lock(PathManager.getJar());
    3    File savedTo = MiscIO.copyJar(root);
    

    If line[2] exclusively locks the jar that contains MiscIO.class, line[3] cannot load MiscIO class.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

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.