Jump to content

Program name: Difference between revisions

→‎{{header|Java}}: Use a system property
m (→‎{{header|C}}: line continuation so __LINE__ is actually on the line)
(→‎{{header|Java}}: Use a system property)
Line 220:
 
=={{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.
Java mainly has notions of classes.
public class Test{
 
<lang java> public classstatic void ScriptNamemain(String[] args){
System.out.println(System.getProperty("sun.java.command").split(" ")[0]);
public static void main(String[] args) {
}
String program = new ScriptName().getClass().getName();
}
System.out.println("Program: " + program);
}
}</lang>
 
=={{header|LLVM}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.