How to compile a single Java file

后端 未结 2 910
傲寒
傲寒 2020-12-13 04:26

I have searched this, but I could\'n find or understand what I found.
Now I\'m not a Java programmer, but I have the need to compile a single Java file into an existing

2条回答
  •  我在风中等你
    2020-12-13 05:05

    You need to have the jar(s) which contains all the things your class depends on to compile it.

    You can then compile the Class with

    javac -classpath jar1:jar2 mypackage.MyNewClass
    

    If you have no access to the original Jars, you will have to create mock classes and method etc (which don't have to do anything, just be there so your class compiles) Using an IDE can make both processes easier. (That is what it is for ;)

提交回复
热议问题