Making a Java Makefile

后端 未结 4 812
时光说笑
时光说笑 2020-12-19 05:59

EDIT: Essentially, I am trying to do the same thing as typing \"javac sim.java\" and then \"java sim (commands)\". Is there a way to replace this using a makefile?

S

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 06:54

    make executes a recipe by executing its dependencies, then the recipe itself. Therefore if you add a command which runs your compiled code to the top recipe, typing 'make' will also run the code after it is compiled. I cannot believe how many people do not know this!

    Something like:

    sim: sim.class
        java sim
    

    Will do what your tutor requires.

提交回复
热议问题