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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:52:59+00:00 2026-05-18T03:52:59+00:00

I have a Java application which runs on an embedded device. Because different devices

  • 0

I have a Java application which runs on an embedded device. Because different devices run different versions of the device SDKs I must build against ~5 different device SDK combinations.

One of these combinations does not support a specific method on an existing object and omits another object entirely from the SDK.

I use this method and object in my program, but only in a certain configuration, so I would like to just fallback to another configuration on devices which do not support it.

I would be happy to do this fallback behavior at compile or run time.

What’s going to be the easiest way to conditionally remove this code?

The code is otherwise identical so I would prefer not to create two separate branches of code for the two SDKs.

I build my application using an Ant script.

My application has to build against a rather old version of the JDK (1.1.8/1.2) if that’s relevant.

  • 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-18T03:52:59+00:00Added an answer on May 18, 2026 at 3:52 am

    One idea is to create two classes with the same interface, a full implementation and a stub, both with an isSupported() method and having all other methods in the stub throw an UnsupportedOperationException. Then I could conditionally include the correct class during compilation in my Ant script.

    I elected to go with this rather than the more dynamic approach @Stephen C because it works perfectly well for our purposes and our access to the device (including the device filesystem) is quite limited, making it difficult to deploy multiple jars, set classpaths, etc.

    What I ended up doing was as follows:

    1. Move the classes which require stubbing into a separate package.
    2. Create a new directory mypackagenamestub and copy the files to be stubbed into it. Make sure that your IDE does not change the package declarations for the files to be stubbed.
    3. We already set the SDK path property in our Ant script based on which SDK the application was being built against, so I added another property omit.unsupportedmode (paraphrased) and set it to true where appropriate.
    4. Use a condition task to set up a value to pass to the excludes attribute of javac, e.g. **/MyPackageStub/** or **/MyPackage/** based on omit.unsupportedmode.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an embedded device which runs Java applications which can among other things
I have an java EE application which has one message-driven bean and it runs
A) If I have a java application which starts up and waits for socket
We have a Java Swing application which contains components like JTable, JCombobox, JTextArea and
I currently have a piece of code in my Android application that picks up
My complete GUI runs inside the AWT thread, because I start the main window
I've written a layered web application that consists of a rich-web client (PHP) that
My Windows's default encoding is GBK, and my Eclipse is totally utf-8 encoded. So
What I am trying to do – Make a JNI call to a shared

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.