Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

java 1.5 on 1.4.2

Thread view: 
oracle - 28 Apr 2005 22:56 GMT
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
Robert - 28 Apr 2005 22:59 GMT
Yeah the compiled .class files shouldn't match.
Gerbrand van Dieijen - 29 Apr 2005 02:00 GMT
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.
Ross Bamford - 29 Apr 2005 02:23 GMT
> oracle schreef:
> > Just need to verify something.
[quoted text clipped - 5 lines]
> 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
Signature

  [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

Tor Iver Wilhelmsen - 29 Apr 2005 08:22 GMT
> 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?
Ross Bamford - 29 Apr 2005 11:10 GMT
> > 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

Signature

  [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

Daniel Sjöblom - 29 Apr 2005 11:40 GMT
> 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.

Signature

Daniel Sjöblom
Remove _NOSPAM to reply by mail

Ross Bamford - 29 Apr 2005 13:00 GMT
On Fri, 2005-04-29 at 13:42 +0300, Daniel Sj=B6blom wrote:

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

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 :)

Signature

  [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

Juha Laiho - 30 Apr 2005 18:44 GMT
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.)
Signature

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)

Gerbrand van Dieijen - 07 May 2005 11:07 GMT
Tor Iver Wilhelmsen schreef:

>>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.
Thomas Schodt - 07 May 2005 11:43 GMT
> 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].
Tony Morris - 07 May 2005 12:49 GMT
> Tor Iver Wilhelmsen schreef:
> >
[quoted text clipped - 6 lines]
> 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

Signature

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/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.