How can I share Java functionality without providing other source code?
When programming in C language, we have header files and source files When our company sells our products (essentially just a useful function library), we only provide the client with header files and compiled source code (not the actual source code) In this way, the client who buys the code can see the function definitions in the header file and call these functions with the compiled code
How do companies that use java development share their library functions without providing code? Because there is no header file in Java, this is only done through documents; That is, provide customers with API documents that display all function signatures, and provide jar files with compiled classes?
Solution
In Java, you don't need to compile the source code - bytecode contains all the metadata you need
So, for example, if I create an interface with some methods, compile it into a class file, then package it into a jar file and provide you with the jar file, you can use the interface and view all its members without source code
Usually, you also provide documentation explaining the meaning of methods, but they are not necessary for compiling against jar files