|
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 |
Eclipse User |
|
|
|
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 #242684 is a reply to message #242670] |
Wed, 11 April 2007 01:51 |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04029 seconds