How to reference Main once only in this ubuntu terminal command: “javac Main.java && java Main”?

后端 未结 3 663
悲哀的现实
悲哀的现实 2021-01-15 10:56

I am reviewing a number of different java programs and am trying to work out how I can update the reference to the program name once only instead of twice. Is there a way t

3条回答
  •  执念已碎
    2021-01-15 11:42

    Sometimes the simplest approach is best. It sounds like you have a bunch of programs to compile and run. I would suggest you put those names into a text file, like this:

    Main
    Foo
    Bar
    

    and then use some search and replace in the editor to make the text like this:

    javac Main.java && java Main
    javac Foo.java && java Foo
    javac Bar.java && java Bar
    

    |Then just select the lines to run and paste them into the terminal.

    Of course, it depends on your expected workflow, but sometimes the simplest is the best.

提交回复
热议问题