Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes

The java.lang.Compiler.command() used to examine the argument type and its fields and perform some documented operation. No specific operations are required.


public static Object command(Object any)


any Specify an argument

Return Value

Returns a compiler-specific value, or null if no compiler is available.


throws NullPointerException, If any is null.


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(); 

    //printing class of y
    Class ycls = y.getClass(); 

    //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