Use the Java interpreter to run Java applications.
The
Java interpreter is the tool used to execute Java applications. In doing so, it translates generic Java
bytecode[1] into native code that executes on a specific platform. The Java interpreter is only used to run stand-alone Java applications and cannot be used to
run
Java applets.
The Java interpreter included with the Java 2 SDK is called
java
, and it's executed like this:
java Memory
In this example, the Java application named Memory is executed using the Java interpreter.
The Java interpreter expects the Memory application to be stored in the executable program file named
Memory.class
.
This application reports how much free memory is available in the Java interpreter along with how much total memory the Java interpreter has access to.
Declaring a type using an interface and then having that interface implemented by a class, adds an extra level of indirection to call the methods that are defined in the interface.
Even in the early days of the
Java interpreter, when acceptable performance was a real concern, this was a minor optimization and it
did not really make much sense. With the current performance of
just-in-time compilers, this objection makes no sense at all.
A second efficiency argument that is often presented against the use of Java interfaces has to do not with the runtime efficiency of the program,
but with the coding-time efficiency of the programmer.
On this argument, interfaces are to be avoided because they duplicate information in the system,
requiring the programmer to do more code entry and create more files.
Why declare an interface, (the arguments by some developers), when all of the information about the
- method names,
- input parameters, and
- return values
will just have to be typed again when implementing a class that implements that interface?
Such thinking misses the importance of interfaces to good systems, and shows a failure to understand how interfaces are part of what makes the type system in Java one of its
best features. The interface defines an
abstraction that a class implementing that interface makes concrete.
Different classes may make the interface abstraction concrete in different ways, but they still have the abstraction that is captured by the interface in common. That Java has a way of expressing what these different implementations have in common is a strength of the language, not a weakness.