I’m trying to implement the following:
public class Main {
public static void main(String[] args) {
//READ FILE IN
String filename = args[0];
System.out.println(filename);
}}
This compiles fine, but when I try to run java br/com/seimos/minijava/Main.java < a or java br/com/seimos/minijava/Main.java a for example, I get an error. Why?? (by the way, I need to get it so that I can do java br/xx/xx.../xx.
Thanks!
EDIT: Sorry, I typed it wrong initially. I DID run java not javac.
The error I get is:
Exception in thread "main" java.lang.NoClassDefFoundError: br/com/seimos/minijava/Main/java
Caused by: java.lang.ClassNotFoundException: br.com.seimos.minijava.Main.java
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
You don’t pass arguments at compile-time, but at runtime.
Java runtime runs the .class bytecode-generated, which is of the name supplied, not the uncompiled
.javasource