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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:39:05+00:00 2026-06-16T20:39:05+00:00

I have some code that uses the proprietary sun.*.OperatingSystemMXBean, so I was being careful

  • 0

I have some code that uses the proprietary sun.*.OperatingSystemMXBean, so I was being careful with it.

try {
    _osBean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
}
catch (ClassCastException e) {
    _osBean = null;
}

However, when this code runs on an IBM JVM, instead of ClassCastException, I get a runtime ClassNotFoundException. Why is this code able to compile just fine if that class is not available and how does a JVM affect something like this?

  • 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-16T20:39:06+00:00Added an answer on June 16, 2026 at 8:39 pm

    the com.sun.* packages are private classes written by sun for the sun JVM (hotspot) and are not public API (even though your code proves they are accessible).
    the IBM JVM is a completely different implementation and doesnt have them (as they are not part of any java/jvm spec).
    im guessing it compiles fine since youre compiling with the sun/oracle JDK
    to try and resolve the issue, try casting to

    java.lang.management.OperatingSystemMXBean
    

    instead (which is a public API) and see if that works for you

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

Sidebar

Related Questions

We have some code kicking around that uses this old internal Sun package for
I have some code that uses the Java Apache POI library to open a
We have some C# code that uses COM (its calling legacy code). When an
I have some code that uses ctypes to try to determine if the file
I have some code that uses the SQL Server 2005 SMO objects to backup
I have some code that uses Open XML to open up a .docx file,
I have some code that uses ODP.Net using (OracleConnection connection = new OracleConnection(connectionString)) {
I have some code here that uses bitsets to store many 1 bit values
I have some old code that uses qsort to sort an MFC CArray of
So I have a chunk of code that declares some classes, creates data, uses

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.