1

I've got a project written using JDK 1.4.1 an JDK 1.7 installed on my machine. I can build those 1.4-sources with the line:

javac @sources.txt -source 1.4 -target 1.4 -deprecation -classpath %cp% -Xstdout log.txt -d .\classes

Is it possible to run it with -source 1.4 -target 1.7 combination?


Also I'm curious will there be any performace gain if I run application written with JDK 1.4.1 on the system where JDK 1.7.1 is installed?

lexeme
  • 2,915
  • 10
  • 60
  • 125
  • Have you read http://stackoverflow.com/questions/10663450/whats-the-difference-between-source-and-target-compatibility ? – D.R. Mar 14 '13 at 12:41
  • Ok, so I can use `-source 1.4 -target 1.7`. Will this work faster on JDK 7 than on JDK 1.4? – lexeme Mar 14 '13 at 13:09
  • Depends on your source code, I guess ;-) I don't think so, however, there are other reasons why one wouldn't want to do that, see: http://stackoverflow.com/questions/8983310/jdk-jre-an-jars-compatibility – D.R. Mar 14 '13 at 13:12
  • I'm appreciated for your useful input. Form it as a question and I'll accept it. – lexeme Mar 14 '13 at 13:15

1 Answers1

1

It is possible, however, I don't think you are winning performance by doing so. Furthermore there are reasons why you do NOT want to do this, see JDK, JRE an JARs compatibility

Community
  • 1
  • 1
D.R.
  • 20,268
  • 21
  • 102
  • 205
  • *String concatenation* would be a reason to target a newer Java version. With `-target 1.4`, it uses `StringBuffer` under the hood, which performs unnecessary synchronization. With `-target 1.5` or higher, including `-target 1.7`, it will use `StringBuilder` which does not perform synchronization. – Holger Apr 18 '23 at 07:28