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 / November 2006

Tip: Looking for answers? Try searching our database.

Interesting problem

Thread view: 
jimlee2004@gmail.com - 10 Nov 2006 18:29 GMT
I have a stupid but interesting question.

Let's say I have 3 java files. a.java, b.java. c.java and a calls b and
b calls c.
If I compile and run them, they works fine.

Assume I use java 1.2 to compile a.java
and then use java 1.5 to compiel b.java
and then use java 1.4 to compile c.java

and then put a.class and b.class and c.class together,
I was wondering if it still run?

In other words, If I collect a bunch of class that compiled from
differenet version of java.
is there any issue to run it? Why or why not?

Thanks,
Thomas Hawtin - 10 Nov 2006 18:40 GMT
> Let's say I have 3 java files. a.java, b.java. c.java and a calls b and
> b calls c.
[quoted text clipped - 3 lines]
> and then use java 1.5 to compiel b.java
> and then use java 1.4 to compile c.java

1.5 defaults to compiling code that only runs on 1.5 or greater.
Therefore the 1.2 compiler will not be able to read the b.class.

Typically you would compile with the latest compiler and set -source,
-target and -bootclasspath to the relevant target JRE.

Tom Hawtin
jimlee2004@gmail.com - 10 Nov 2006 19:00 GMT
Thanks,

what if I run on a 1.5 jre? It should be ok , right?
In other words, if the jre is higher than any of the .class run, it
should run.
But not the otherway around ( that's what I want to confirm)

> > Let's say I have 3 java files. a.java, b.java. c.java and a calls b and
> > b calls c.
[quoted text clipped - 11 lines]
>
> Tom Hawtin
Daniel Pitts - 10 Nov 2006 19:24 GMT
> Thanks,
>
[quoted text clipped - 18 lines]
> >
> > Tom Hawtin

Kind of, you couldn't compile a.java, since the compiler needs to look
at b.java.

So, the short answer is, if you get it to compile, it should work.  The
longer answer is, you should try to be consistent in your codebase.  If
you need to use Java 1.5, then use it all the way around.  Most java
1.2/1.4 code (not all) will compile in 1.5 just fine.  If you are
having trouple with it, try to fix the J2 code to work with J5.
jimlee2004@gmail.com - 10 Nov 2006 19:35 GMT
The reason I am asking this question is because I have the following
scenario.

Let's assume I delivered an application which contains a.class.b.class,
c.class

later on, I put some enhancement to c.java and want to delivery it to
client.
however, I can't redelivery a.class and b.class.

can I simply give c.class to them and ask them to replace their old
c.class?
(Given the fact that I don't know exactly which jre version they are
running?)
Daniel Pitts - 10 Nov 2006 19:40 GMT
jimlee2...@gmail.com wrote:
> The reason I am asking this question is because I have the following
> scenario.
[quoted text clipped - 10 lines]
> (Given the fact that I don't know exactly which jre version they are
> running?)

You'd have to compile class c under the lowest common denominator.
Meaning, if you possibly had clients with JRE1.2, then you'd have to
write the class for 1.2.
The alternative is to have the clients upgrade JRE's, and supply them
with a fresh build, rather than a patch.
It becomes complicated to keep track of "patches" if you do it file by
file.

"This client has a.class version 1, b.class version 32, and c.class
version 14.  c.class version 15 isn't compatible with a.class version
1, but is with a.class version 3, but a.class isn't compatible with
b.class version 32." etc... etc...

Put everything in a single Jar file, then you can upgrade it all at
once.


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.