Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JDK 5.0 and Compiler compliance level set to 1.4
JDK 5.0 and Compiler compliance level set to 1.4 [message #242661] Tue, 10 April 2007 15:12 Go to next message
Saurabh Dravid is currently offline Saurabh DravidFriend
Messages: 20
Registered: July 2009
Junior Member
Hi,

I am using the Eclipse SDK of Build "3.3M6" and Sun Java 1.5.

Following is the output of Java -version

java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

When I set the Compiler Compliance Level to 1.4 and use the Java 1.5.
I didn't get the compilation error in following piece of code.

String str = null;
str.contains("hi");

How can I make sure that my code will compile properly with Java 1.4 even
though I had installed Java 1.5 and set the Compiler Compliance Level to
1.4.

Thanks
Re: JDK 5.0 and Compiler compliance level set to 1.4 [message #242666 is a reply to message #242661] Tue, 10 April 2007 15:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Saurabh dravid" <sadravid@in.ibm.com> wrote in message
news:e9f907360e835fd5bf3a48af4a860799$1@www.eclipse.org...
> Hi,
>
> I am using the Eclipse SDK of Build "3.3M6" and Sun Java 1.5.
>
> Following is the output of Java -version
>
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
>
> When I set the Compiler Compliance Level to 1.4 and use the Java 1.5.
> I didn't get the compilation error in following piece of code.
>
> String str = null;
> str.contains("hi");
>
> How can I make sure that my code will compile properly with Java 1.4 even
> though I had installed Java 1.5 and set the Compiler Compliance Level to
> 1.4.

You may notice that if you use javac 1.5 (from Sun), and you compile that
code with javac -source 1.4, you also do not get an error. However, if you
use javac 1.4, you do get an error, that .contains is missing.

The reason is that the error has nothing to do with the Java language
definition; it has to do with what java runtimes you're linking to. In the
java 1.4 version of rt.jar, String has different methods than in 1.5.

So, make sure to set your JRE appropriately on the Java build path, as well
as setting the compiler compliance. Then you'll get the error you're
expecting.
Re: JDK 5.0 and Compiler compliance level set to 1.4 [message #242670 is a reply to message #242661] Tue, 10 April 2007 20:43 Go to previous messageGo to next message
Shankar Unni is currently offline Shankar UnniFriend
Messages: 19
Registered: July 2009
Junior Member
Saurabh dravid wrote:

> String str = null;
> str.contains("hi");

As the other poster (Walter) said: this is the official stance from Sun:
it's not a "language" difference, but a difference in the API.

Setting -source 1.4 only selects which language syntax features are
enabled (e.g. generics, enhanced for loop, etc.). To truly get a 1.4
compilation, you need a 1.4 JRE also available at compilation time, and
use the -bootclasspath option to javac to point it at the rt.jar in the
1.4 JRE.
Re: JDK 5.0 and Compiler compliance level set to 1.4 [message #242684 is a reply to message #242670] Wed, 11 April 2007 01:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kwarner.uneedspeed.net

I have my Eclipse set up so that I can compile with 1.4 -- that wasn't too hard.

My question: what is the compliance level one needs to go down to inorder
to run an applet under the old MS JVM. I set the generated class compatablitiy
to 1.2 -- applet jar wouldn't load. Error message said it couldn't find
packagename.applet.class

The jar loads fine in the plugin....

Do I need to set the generated class compatability all the way down to 1.1?????

Shankar Unni wrote:
> Saurabh dravid wrote:
>
>> String str = null;
>> str.contains("hi");
>
>
> As the other poster (Walter) said: this is the official stance from Sun:
> it's not a "language" difference, but a difference in the API.
>
> Setting -source 1.4 only selects which language syntax features are
> enabled (e.g. generics, enhanced for loop, etc.). To truly get a 1.4
> compilation, you need a 1.4 JRE also available at compilation time, and
> use the -bootclasspath option to javac to point it at the rt.jar in the
> 1.4 JRE.
Re: JDK 5.0 and Compiler compliance level set to 1.4 [message #242728 is a reply to message #242684] Wed, 11 April 2007 14:42 Go to previous message
Jeff Care is currently offline Jeff CareFriend
Messages: 23
Registered: July 2009
Junior Member
DemonDuck wrote:
> I have my Eclipse set up so that I can compile with 1.4 -- that wasn't
> too hard.
>
> My question: what is the compliance level one needs to go down to inorder
> to run an applet under the old MS JVM. I set the generated class
> compatablitiy
> to 1.2 -- applet jar wouldn't load. Error message said it couldn't find
> packagename.applet.class
>
> The jar loads fine in the plugin....
>
> Do I need to set the generated class compatability all the way down to
> 1.1?????

For the MS VM, yes.

--
Jeffrey E. (Jeff) Care carej@us.ibm.com
WebSphere Application Server Systems Management Development
Previous Topic:IResource.exists() problem
Next Topic:Proposal for a new useful (?) Eclipse plugin
Goto Forum:
  


Current Time: Thu Jan 02 22:30:17 GMT 2025

Powered by FUDForum. Page generated in 0.04029 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top