f



java 1.5 on 1.4.2

Just need to verify something.

You can not use a java 1.5 war file on a machine with java 1.4.2 loaded
on it.  

Is this not right???

Thanks

0
cysneros (3)
4/28/2005 9:56:03 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

11 Replies
543 Views

Similar Articles

[PageSpeed] 5

Yeah the compiled .class files shouldn't match.

0
4/28/2005 9:59:16 PM
oracle schreef:
> Just need to verify something.
> 
> You can not use a java 1.5 war file on a machine with java 1.4.2 loaded
> on it.  
> 

That depends, you can compile Java 1.5 source code to a 1.4 class file.
Then it will run fine on a java 1.4.2 JVM, even with the use of
generics, and other java 1.5 extensions.
0
twistedmnd (49)
4/29/2005 1:00:24 AM
On Fri, 2005-04-29 at 03:00 +0200, Gerbrand van Dieijen wrote:
> oracle schreef:
> > Just need to verify something.
> > 
> > You can not use a java 1.5 war file on a machine with java 1.4.2 loaded
> > on it.  
> > 
> 
> That depends, you can compile Java 1.5 source code to a 1.4 class file.
> Then it will run fine on a java 1.4.2 JVM, even with the use of
> generics, and other java 1.5 extensions.

Hmm, I'd like a copy of your JVM... You can specify to javac the Source
Code and Target JVM versions you require. Specifying a lower Target
requires also that you set a lower Source. 

So you can compile, for example, for 1.4, using:

javac -source 1.4 -target 1.4 MyClass.java

However, if MyClass.java uses *any* JDK 1.5 specific features (Generics,
For-each loop, etc), you'll get:

MyClass.java:5: generics are not supported in -source 1.4
(try -source 1.5 to enable generics)
   static Vector<MyClass> v = new Vector<MyClass>();
                ^
1 error

(as already mentioned, the -source argument is mandatory in this case,
although I'm not sure if it implies the target).

Ross
-- 
   [Ross A. Bamford]     [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@the.website.domain


0
ross5742 (163)
4/29/2005 1:23:08 AM
Ross Bamford <ross@read.the.sig> writes:

> MyClass.java:5: generics are not supported in -source 1.4
> (try -source 1.5 to enable generics)
>    static Vector<MyClass> v = new Vector<MyClass>();

Why not try -source 1.5 -target 1.4?
0
4/29/2005 7:33:36 AM
On Fri, 2005-04-29 at 09:33 +0200, Tor Iver Wilhelmsen wrote:
> Ross Bamford <ross@read.the.sig> writes:
> 
> > MyClass.java:5: generics are not supported in -source 1.4
> > (try -source 1.5 to enable generics)
> >    static Vector<MyClass> v = new Vector<MyClass>();
> 
> Why not try -source 1.5 -target 1.4?

Why don't you? :)

Quote: "javac: source release 1.5 requires target release 1.5"

You have to understand that Java isn't Perl - it's not interpreted. New
*language* features introduce new *opcodes* which a 1.4 JVM would
probably class as Invalid (look at ClassLoader/SecurityManager).

Javac obviously won't let you specify 'Generate these special 1.5
Opcodes, and then target them for a JVM that's never heard of them".

Cheers,
Ross

-- 
   [Ross A. Bamford]     [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@the.website.domain


0
ross5742 (163)
4/29/2005 10:10:54 AM
Ross Bamford wrote:

> You have to understand that Java isn't Perl - it's not interpreted. New
> *language* features introduce new *opcodes* which a 1.4 JVM would
> probably class as Invalid (look at ClassLoader/SecurityManager).

I'm not aware of any new opcodes being introduced in a long time. There 
is one new variation on the ldc instruction in java 1.5, which however 
does not do anything that couldn't be done before (it loads a class 
literal.) It is however impossible to compile all 1.5 source to 1.4 
bytecode. The most obvious problems are lack of an annotation 
specification in the 1.4 class file format, and also the need for 
generic signatures, also not present in 1.4.

-- 
Daniel Sj´┐Żblom
Remove _NOSPAM to reply by mail
0
dsjoblom (223)
4/29/2005 10:42:39 AM
On Fri, 2005-04-29 at 13:42 +0300, Daniel Sj=C3=B6blom wrote:

> I'm not aware of any new opcodes being introduced in a long time.=20

Of course you're right - I said it without thinking, just to try to get
across why it doesn't work. The intent remains the same, that the core
JVM doesn't understand the class file structure.

Sorry for confusion :)

--=20
   [Ross A. Bamford]     [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@the.website.domain


0
ross5742 (163)
4/29/2005 12:00:34 PM
Ross Bamford <ross@read.the.sig> said:
>You have to understand that Java isn't Perl - it's not interpreted.

Apologies for taking this completely off-topic, but just for the record,
Perl isn't interpreted, either - it's compiled into bytecode, but the
compilation results are not (normally) permanently stored. Instead,
there's a compilation phase each time you run a Perl program.

From documentation:
       After locating your program, Perl compiles the entire program to an
       internal form.  If there are any compilation errors, execution of the
       program is not attempted.  (This is unlike the typical shell script,
       which might run part-way through before finding a syntax error.)
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
0
Juha.Laiho (700)
4/30/2005 5:44:54 PM
Tor Iver Wilhelmsen schreef:
> Ross Bamford <ross@read.the.sig> writes:
> 
> 
>>MyClass.java:5: generics are not supported in -source 1.4
>>(try -source 1.5 to enable generics)
>>   static Vector<MyClass> v = new Vector<MyClass>();
> 
> 
> Why not try -source 1.5 -target 1.4?

I use these paramaters, and it works fine. Maybe it doesn't work for all
1.5 extensions, but it works fine for generics.
0
twistedmnd (49)
5/7/2005 10:07:23 AM
Gerbrand van Dieijen wrote:

> I use these paramaters, and it works fine. Maybe it doesn't work for all
> 1.5 extensions, but it works fine for generics.

What does "javah -version" say?
[Or "javac -version" if javac now does -version].
0
spamtrap4926 (241)
5/7/2005 10:43:02 AM
"Gerbrand van Dieijen" <twistedmnd@hotmail.com> wrote in message
news:d0185$427c9363$9161dfd0$514@news1.tudelft.nl...
> Tor Iver Wilhelmsen schreef:
> > Ross Bamford <ross@read.the.sig> writes:
> >
> >
> >>MyClass.java:5: generics are not supported in -source 1.4
> >>(try -source 1.5 to enable generics)
> >>   static Vector<MyClass> v = new Vector<MyClass>();
> >
> >
> > Why not try -source 1.5 -target 1.4?
>
> I use these paramaters, and it works fine. Maybe it doesn't work for all
> 1.5 extensions, but it works fine for generics.

No, you cannot use -source 1.5 -target 1.4.
You want to look at the undocumented compiler switch -jsr14.
If you are using source level 1.5, why are you using a data type
(java.util.Vector) that was obsoleted 7 or 8 years ago?
http://qa.jtiger.org/GetQAndA.action?qids=53

-- 
Tony Morris
Software Engineer, IBM Australia.
BInfTech, SCJP 1.4, SCJD

http://www.jtiger.org/ JTiger Unit Test Framework for Java
http://qa.jtiger.org/ Java Q&A (FAQ, Trivia)
http://xdweb.net/~dibblego/


0
not147 (631)
5/7/2005 11:49:22 AM
Reply: