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

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>