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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:00:04+00:00 2026-05-29T10:00:04+00:00

I have a Java application on a USB stick along with the JRE (one

  • 0

I have a Java application on a USB stick along with the JRE (one for each Windows, Mac OSX and Linux) so that it can be run on any system even when Java is not installed. I have a thread running to detect if the USB stick is removed and if it is it exits the application.

I want to have it display a message before exiting (or tell them to re-insert the drive) but if I try to dispaly a JOptionPane I get the NoClassDefFoundError because the JRE has been removed along with the USB.

Is there a way to keep the needed classes in memory so that Java does not try to load them from the filesystem that is no longer present?

Thanks!

  • 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-29T10:00:06+00:00Added an answer on May 29, 2026 at 10:00 am

    For most runtimes, any classes that are loaded will be in RAM, in the PermGen section of Java’s memory.

    To my mind what’s likely happening is that displaying the error requires classes that haven’t been loaded before – which are only available on the drive that’s no longer there.

    You might be able to work around this by triggering your error displaying logic when the program starts up, except have it in a mode where it’s displayed invisibly. This should exercise the same code path such that all the required classes are loaded, and ensure that they’re already known when you need to display your error. If this is too difficult, you could just manually call Class.forName("javax.swing.JOptionPane") instead (for each class required), though this is more brittle and likely to break if you change your rendering code without updating the hard-coded classes to load.

    If this isn’t the case (i.e. all the required classes have previously been loaded, and you still have the problem) then your runtime is obviously unloading classes. You’d have to look at its documentation to see what it’s doing here, and how to stop it.

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

Sidebar

Related Questions

I have a java application that can be run as a JFrame or as
I have a Java application that launches another java application. The launcher has a
I have a Java application that monitors a folder for incoming XML files. When
I have a Java application that's very String-heavy - it takes a feed of
I have a java application that has Web Services published using Axis. With the
I have a java application that is connected to a view on a remote
We have a Java application that needs to be brought to the foreground when
I have java application that is crashing while in production. It doesn't do so
I have Java Desktop application that displays some information in a JTable that contains
I have Java desktop application that works with CSV files. And i want add

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.