Using mix mode compiling

M

mailmetosandeep

Can anyone suggest me a way wherein I can use java 1.5 features and the
source is compilable with 1.4
I tries out javac -source 1.4
But by doing so I am not able to use java 1.5 features
If I try to use 1.5 then there are errors on my 1.4 code i.e enum has
been reffered as an object ref but in 1.5 it is an type

I do not want to modify my 1.4 code and also wants to use 1.5 features
as well
Can someone suggest some way out for this

Suppose my class looks like

import java.util.Enumeration;
public class Hello {
public static void main(String[] args) {
System.out.printf("hello world"); // 1.5 feature
Enumeration enum ; // enum is a type in 1.5
}
}

Now I want to compile it in a go


Thanks in Advance
Sandeep
 
M

Manish Pandit

You need to pick what you want to do. You cannot use 1.5 features
without your source being 1.5 compatible. Can you elaborate why you
want to keep your target vm to 1.5 despite coding in 1.5?

Even the -target and -source directives will not allow you to have 1.5
source compiled to a lower version bytecode.

-cheers,
Manish
 
M

Manish Pandit

Oops!
want to keep your target vm to 1.5 despite coding in 1.5?

Please read

want to keep your target vm to 1.4 despite coding in 1.5?

-cheers,
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top