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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:05:33+00:00 2026-05-14T00:05:33+00:00

I want to be able to support multiple versions of Java ME without having

  • 0

I want to be able to support multiple versions of Java ME without having to have multiple builds. I already know how to detect the profile/configuration/supported JSRs. My problem is that knowing whether the JSR is supported at run time doesn’t allow me to use all the features as Java-ME does not provide support for reflection.

For if I call a function added in a later version anywhere in the code – even a location that will never be run, then this could cause an error during resolution on some JVMs. Is there any way round this?

Related Questions

  • Handling optional APIs in J2ME
  • 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-14T00:05:33+00:00Added an answer on May 14, 2026 at 12:05 am

    If you only need to access the class C through an interface which you know you will have access to, then it is simple enough:

    MyInterface provider=null;
    try{
        Class myClass= Class.forName("sysPackage.C");
        provider = (MyInterface)(myClass.newInstance());  
    }catch(Exception ex){
    }
    if(provide!=null){
        //Use provider
    }
    

    If C does not have an interface that can be used, then we can instead create a wrapper class S that will be a member of the interface instead.

    class S implements MyInterface{
        static {
            try {
                Class.forName("sysPackage.C");
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        } 
        public static void forceExceptionIfUnavailable() {}
        //TODO: Methods that use C. Class C will only be used within this class
    }   
    

    S has a static block so that an exception is thrown during class resolution if C is unavailable. Immediately after loading the class, we call forceExceptionIfUnavailable to make sure that the static block is run immediately. If it doesn’t crash, then we can use the methods in S to indirectly use class C.

    Alternatively, we can use the method here:

    Basically, you create a new package P, with a public abstract class A and a concrete subclass S private to the package. A has a static method getS that returns an instance of S or null if an exception is thrown during instantiation. Each instance of S has an instance of C so it will fail to instantiate when C is unavailable – otherwise it will succeed. This method seems to be a bit safer as S (and hence all the C APIs) are package private.

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

Sidebar

Ask A Question

Stats

  • Questions 411k
  • Answers 411k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Thank you! This is a great example to show off… May 15, 2026 at 7:40 am
  • Editorial Team
    Editorial Team added an answer For this particular example, it looks like the dict method… May 15, 2026 at 7:40 am
  • Editorial Team
    Editorial Team added an answer You're encountering a many-to-many relationship. Example: Rep_GroupNode MappingTable ------------- ------------------------… May 15, 2026 at 7:40 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.