Talk:Program name

From Rosetta Code

Java entry

The Java entry is kind of funny because it requires you to type the name of the class in order to print it. Then you might as well print it directly. It really should be using reflection. I've never used reflection in Java, but a after a glance at the documentation, I came up with this.

<lang java>public class Test {

  public static void main(String[] args) {
      Class c = new Object().getClass().getEnclosingClass();
      System.out.println(c.getName());
  }

}</lang>

Question on the goal of the task

Hi, Is it to:

  1. Give the name of the executable for compiled code
  2. Give the name of the file being interpreted in the case of interpreted code.

The task description seems OK for interpreters, but the C example does not fit the task. Maybe the task description needs an update? --Paddy3118 02:43, 6 August 2011 (UTC)