Program name: Difference between revisions

(→‎{{header|Java}}: Use a system property)
Line 221:
=={{header|Java}}==
You can get the listing of the arguments to the <code>java</code> command through a system property. The first one is the name of the main class that was run.
<lang java>// Thanks to Mwn3d
public class Test{
public static voidclass main(String[]ScriptName args){
public static void main(String[] args) {
String program = System.out.println(System.getProperty("sun.java.command").split(" ")[0]);
}
System.out.println("Program: " + program);
}
}</lang>
 
=={{header|LLVM}}==
Anonymous user