Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Interesting problem

Reply
Thread Tools

Interesting problem

 
 
jimlee2004@gmail.com
Guest
Posts: n/a
 
      11-10-2006
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,

 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      11-10-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
>
> 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


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
 
Reply With Quote
 
 
 
 
jimlee2004@gmail.com
Guest
Posts: n/a
 
      11-10-2006
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)

Thomas Hawtin wrote:
> (E-Mail Removed) wrote:
> >
> > 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

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


 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-10-2006

(E-Mail Removed) wrote:
> 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)
>
> Thomas Hawtin wrote:
> > (E-Mail Removed) wrote:
> > >
> > > 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

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


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.

 
Reply With Quote
 
jimlee2004@gmail.com
Guest
Posts: n/a
 
      11-10-2006
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?)

 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      11-10-2006

(E-Mail Removed) wrote:
> 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?)


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting nat problem G.G. Cisco 2 12-02-2005 09:22 PM
Interesting problem with NAT and VPN (not the usual question) Jim Westwood Cisco 6 10-15-2005 05:07 PM
Interesting ping problem Cpt_CAM Cisco 2 04-18-2005 08:51 AM
Interesting Ping Problem with Gigaman Circuits and Cisco 4006 Switches - Anyone? Cpt_Cam Cisco 7 10-05-2004 05:29 AM
BGP and NAT... interesting problem Gollum Cisco 3 12-17-2003 06:22 PM



Advertisments