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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:58:08+00:00 2026-06-11T16:58:08+00:00

Suppose I want to write an application that is targeting some JRE version (e.g.

  • 0

Suppose I want to write an application that is targeting some JRE version (e.g. 1.6), but on the machine that I use to develop it, there is a newer version of the JRE installed (e.g. 1.7).

The naive approach is to set the compiler level to 1.6 (I use Eclipse, but that’s probably not very important, since the problem is general). However, that is not sufficient. Setting the source level for the compiler ensures that the source files use only the language features available for that Java version and therefore the generated class files have the right minor version, so the target JVM will be able to load and run them.

But there is another and more subtle problem: If I use a class or a method in my code which was added in 1.7 and try to run the app on the machine with 1.6 runtime installed, it fails with a NoClassDefFoundError or a NoSuchMethodError.

The problem is that the same program runs fine on the dev machine, because the 1.7 JDK installed on it does contain these classes. The compiler or the IDE do not complain either. The only indicators that I’m referencing classes and methods that won’t be available are the Since 1.7 comments in JavaDoc.

So how to ensure that I never use classes or methods that won’t be available in an older version of the JRE? Is the only reliable solution to always have the exact target JRE version on the build path? That would mean that I would need to install an extra JDK on my dev machine for every such case (1.7, 1.6, possibly 1.5, maybe even 1.4).

  • 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-11T16:58:09+00:00Added an answer on June 11, 2026 at 4:58 pm

    Use the bootcpasspath option pointing to a 1.6 JRE (specifically the rt.jar) during compilation. Doing so will force a check that all referenced classes, methods and attributes are actually present in the supplied rt.jar.

    See the javac – cross-compilation options for more details.

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

Sidebar

Related Questions

Suppose I want to write an app for Android OS that is not going
Suppose that I have a method called doSomething() and I want to use this
Suppose I have some application A with a database. Now I want to add
Suppose, you want to write unittest s for functions like this one: def test_me(instream):
Suppose I want to put objects that identify a server into a stl set
Suppose I want to make a Web application which uses a fixed width and
Just a technology update, now that .NET 4.0 is out. I write an application
BACKGROUND : I now understand how to write a C# application that can monitor
I am creating Windows Application in C# in which I want to write in
i am creating windows application in C# in which i want to write in

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.