Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac -target 1.3 hello.java

 
Kumar Sushil
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
when we use a higher version, but want that our application run also on lower version of JDK also, then we use
c:\>javac -target 1.3 hello.java
here file name is hello.java and currently we are useing JDK1.5 and we want byte code of hello.java that is compatable to jdk1.3.
This command does not run on jdk1.5 but this run on jdk1.4.

I want to know that -target option command runs or not on jdk1.5.

please tell me
 
Edisandro Bessa
Ranch Hand
Posts: 584
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi johny,

Here is the command : javac -source 1.3 OldCode.java

You can face a compiler warning if you have in your code some variable named assert.

If you want to compile your code for version 1.4 the command is javac -source 1.4 OldCode.java

Using the 1.4 version you will get a compile error if your code has some variable called as assert
 
vishnu hiranamayee
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assertion is added in java's 1.4 version then why will we get a complier error in 1.4.
please let me know.
 
Bharat Roy
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a target option too but I guess thats for J2ME.
 
Bharat Roy
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDK 1.4 --- assert is NOT a keyword until you compile it against -source 1.4 option.

JDK 1.5 --- assert IS a keyword by default. If you want to use assert as a variable name (which you should not) compile it against -source 1.3 option. (It will show you warning though)
 
Bharat Roy
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vishnu hiranamayee:
assertion is added in java's 1.4 version then why will we get a complier error in 1.4.
please let me know.


You will get compiler error ONLY if you are using assert as a variable name and also compiling the code against -source 1.4 option.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refrain form duplicate posting the same question.

Also, this forum is for the SCJP exam. Your question is not something that appears on the exam. So I am moving this to Java In General (Beginner)

Thanks and good luck.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic