Java - Compiler command() Method
The java.lang.Compiler.command() used to examine the argument type and its fields and perform some documented operation. No specific operations are required.
Syntax
public static Object command(Object any)
Parameters
any |
Specify an argument |
Return Value
Returns a compiler-specific value, or null if no compiler is available.
Exception
throws NullPointerException, If any is null.
Example:
The below example shows how to use java.lang.Compiler.command() method.
public class MyClass { public static void main(String[] args) { Integer x = new Integer("10"); String y = "Hello"; //printing class of x Class xcls = x.getClass(); System.out.println(xcls); //printing class of y Class ycls = y.getClass(); System.out.println(ycls); //compile MyClass using command method Object retval = Compiler.command("javac MyClass"); System.out.println("Return Value = " + retval); } }
The output of the above code will be:
class java.lang.Integer class java.lang.String Return Value = null
❮ Java.lang - Compiler