I'm trying to run a Java code using on Intelij IDEA passing a .txt file as argument.
I followed this up this discussion but it didn't help much Run Program from IntelliJ with Command Line File Input
Also, I trid the EXACT same thing (I guess..) in another computer and it worked, but in my personal computer I have a newer version of Intelij and some little things are different. I don't know if something has changed or if I'm doing something wrong...
Here is my code:
public static void main(String[] args) {
// read the n points from a file
StdOut.println("Args: " + Arrays.toString(args));
StdOut.println("Args: " + args[0]);
}
My configurations:
And the output:
Args: []
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at BruteCollinearPoints.main(BruteCollinearPoints.java:89)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:128)
Process finished with exit code 1
If I run this code at the console everything goes fine.