File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes javac -version? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "javac -version?" Watch "javac -version?" New topic

javac -version?

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I know you can type "java -version" to get the version of the JRE that will be used from the command line. As far as I have seen, there is no equivalent for javac, though? Does anyone know why not? Or am I just retarded and can't find it. I can easily imagine a situation where the javac executable is a different version from the java executable. (In fact, I have encountered this lately because on a particular machine that I use "java -version" reports that it is indeed using Java 1.5. However, javac is complaining about generics and other new syntax. Does anyone have any ideas about this?


Java API Documentation
The Java Tutorial
Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
Really it's variable, because you can assign which release you want to use as long as the release version you use is earlier then the one you are compiling with. So how to find what the latest version javac is using to compile?
javac -source 1.5

If it is using 1.5 javac you get message "no source files"
If it is not using 1.5 you get message "invalid source release"

Run the same test using 1.4, 1.3 ... on and on..


Jimmy Die
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
Try "javac -J-version" unless you're using Java 5 which has a -version switch on javac.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Thanks for the suggestions. That seems to give me the information I am looking for. Strangely a machine I have an account on has the version 1.5 for java, but only 1.4 for javac. I'll have to ask an admin about that.

I agree. Here's the link:
subject: javac -version?
It's not a secret anymore!