Java Tools

Compile Java Code: (http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/javac.html)

% ls
classes/  lib/      src/
% ls src
farewells/
% ls src/farewells
Base.java      GoodBye.java
% ls lib
Banners.jar
% ls classes
% javac -target 1.4 -sourcepath src -classpath classes:lib/Banners.jar src/farewells/GoodBye.java -d classes
% ls classes
farewells/
% ls classes/farewells
Base.class      GoodBye.class

Note: The compiler compiled src/farewells/Base.java, even though we didn't specify it on the command line. To trace automatic compiles, use the -verbose option.


Check java class version:

Java platform version major minor
1.0 45 3
1.1 45 3
1.2 46 0
1.3 47 0
1.4 48 0
1.5/5.0 49 0
1.6/6.0 50 0
1.7/7.0 51 0

run this:

javap -verbose Main1

see output:
Compiled from "Main1.java"
class Main1 extends java.lang.Object
  SourceFile: "Main1.java"
  minor version: 0
  major version: 48

in unix/linux, you can also do:

$ file Main1.class

see output:
Main1.class: compiled Java class data, version 48.0 (Java 1.4)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License