user1101253
user1101253

Reputation: 1

Java portability different OS/JDK

I am new on "java world" so I need to know the basics about portability in different OS and JDK. What I am seeing in internet is that if a compile a program on JDK 1.7, it will run on any JDK version >= 1.7, is it right? Thanks, and my apologies about my english it is not my default language.

Upvotes: 0

Views: 298

Answers (3)

kosa
kosa

Reputation: 66637

Yes, unless something deprecated in newer versions. Deprecation may result in some inconsistence.

Upvotes: 0

BillRobertson42
BillRobertson42

Reputation: 12883

You are correct. Most of what you write will automatically work in any (version compatible) JVM. I moved an significant Java Swing GUI application from Windows to Linux, and I only had to change the config files to point to different directories. It just works.

Upvotes: 0

Sumit Singh
Sumit Singh

Reputation: 15886

there is a option in java -target version
it says that...

Generate class files that target a specified version of the VM. Class files will run 
on the specified target and on later versions, but not on earlier versions of the VM.
Valid targets are 1.1, 1.2, 1.3,1.4, 1.5 (also 5), 1.6 (also 6), and 1.7 (also 7).  

       If -source is not specified, the value of -target is 1.7  
       If -source is 1.2, the value of -target is 1.4  
       If -source is 1.3, the value of -target is 1.4  
       If -source is 1.5, the value of -target is 1.7  
       If -source is 1.6, the value of -target is 1.7 
       For all other values of -source, the value of -target is the value of -source.  

so " if a compile a program on JDK 1.7, it will run on any JDK version >= 1.7, is right"

Upvotes: 1

Related Questions