0

I'm building a desktop app on Java (11) and compiled with Maven, but I need to send a Filepath as an argument to read it:

public class App {
public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("File name not specified.");
        System.exit(1);
    }
    System.out.println(args[0]);

    readFile(args[0]);
}
}

I don't know how to run the app sending that parameter or which command is needed in the Command Line

3
  • How have you compiled with Maven? Do you have an executable jar file? Next, what platform are you using? Finally, what filepath do you want to send? Assuming it's a jar and you're on Windows, java -jar my.jar "C:/Some File/Path.txt" Commented Sep 28, 2022 at 21:29
  • stackoverflow.com/questions/10108374/… Commented Sep 28, 2022 at 21:45
  • It worked, thank you, sorry I didn't know I need a Jar, about the questions, yes I tried with Maven but in my ignorance, maybe I did it wrong, also, yes, I'm on Windows and the filepath could be any since will be a User input, but it worked having the Jar, thanks! Commented Sep 28, 2022 at 21:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.