wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes javac -target 1.3 hello.java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac -target 1.3 hello.java" Watch "javac -target 1.3 hello.java" New topic
Author

javac -target 1.3 hello.java

Kumar Sushil
Greenhorn

Joined: Jan 31, 2006
Posts: 29
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

Joined: Jan 19, 2006
Posts: 584
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


"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
vishnu hiranamayee
Greenhorn

Joined: Feb 23, 2006
Posts: 17
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

Joined: Jul 01, 2004
Posts: 156
There's a target option too but I guess thats for J2ME.
Bharat Roy
Ranch Hand

Joined: Jul 01, 2004
Posts: 156
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

Joined: Jul 01, 2004
Posts: 156
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Consider Paul's rocket mass heater.
 
subject: javac -target 1.3 hello.java