• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doing javac -source 1.5 MyClass.java

 
Werner van Mook
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Although I'm not a beginner I do have a very basic java question.

I have the following class :

public class IntTest
{

public static void main(String[] args)
{
Integer i = 100;
Integer i2 = 100;
System.out.println((i == i2)? "Yes equal": "Nope not equal");

}
}

I want to compile this class on a win2000 system with jdk 1.5 installed.
java -version gives me :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

If I'm correct : I want to compile this. because I use autoboxing I have to compile this using the -source 1.5 flag.

If I do : javac -source 1.5 MyClass.java
I get :
javac: invalid flag: -source
Usage: javac <options> <source files>
where possible options include:......... etc.

What am I doing wrong?

Kind regads
 
Igor Stojanovic
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use , it should work.
 
Werner van Mook
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry

It does not work.

Integer i = 100;

does not work in 'standard' java.
you have to tell the compiler to use the 'new and improved' java features.
Normally you do that by telling the compiler that you will use special things in your source.
You tell the compiler : 'hey compiler I use special 1.5 code'

you do that by javac -source 1.5 YourClassNameHere.java

A pre 1.5 example would be :

using assert in your 1.4 code.

When I do that I have to compile with javac -source 1.4 MyClass.java (with a 1.4 JDK that is. I don't know if I still have to do that with a 1.5 JDK)

Regrads
Werner
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not post the same question in multiple forums. It makes the discussion harder to follow.
Originally posted by Werner van Mook:
java -version gives me :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
What does the following give you?
 
Igor Stojanovic
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Werner,

I have java version "1.5.0"
Java<TM> 2 Runtime Environment, Standard Edition <build 1.5.0-b64>
Java HotSpot<TM> Client VM <build 1.5.0-b64, mixed mode,sharing>

and it works for me.



javac Jdk.java //no problem here

java Jdk
Output: 100

Maybe its something different because I use win XP ?



kind regards
Igor
 
Werner van Mook
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well that can be my problem.
Look at the version of your java and mine :

Mine is : 1.5.0_01-b08
Yours is : 1.5.0_01-b64

I downloaded the newest JDK and when installing it tells me it is already installed.

Very strange.
 
Werner van Mook
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just checked it with someone else.
He also ha the 1.5.0-01-b64 version and he can do -source.

I think I have to uninstall my version and do a clean install of the newest 1.5 SDK.

I will come back on this when I'm finished.

Thanx so far to all of you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic