1

I'm learning SedgeWick's 《algorithm4》and I often need to debug the code in the book. but I can't run or debug directly by IDE button because there have many example code need set args in command line like:

java -cp ../../algs4.jar RandomSeq.java 20 50 60
java -cp ../../algs4.jar BinarySearch.java tinyW.txt < tinyY.txt

enter image description here

I want to debug java class with command args but I have no idea how to make it.

Joachim Sauer
309k59 gold badges568 silver badges624 bronze badges
asked May 29, 2021 at 7:22
2
  • 3
    You seem to be starting your Java application manually from the built-in Terminal in IntelliJ IDEA. This means you're not really using the Java capabilities of IDEA at all. You should instead launch it via a Run/debug configuration. There you can specify command line arguments if you like and then launch it either in "normal" mode or "debug" mode. If you just click "run" on a class, it will create a launch configuration for you that you can then edit to include the arguments that you want. Commented May 29, 2021 at 7:28
  • Thanks,that solve my problem. Commented May 29, 2021 at 7:53

1 Answer 1

0

Use Run/Debug Configuration for Java Application and specify a Main class and Program arguments in the Run Configuration dialog:

enter image description here

answered May 31, 2021 at 14:25
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.