Reputation: 281
Suppose I want to use a class that someone else wrote in java, do I need to get access to the source code itself or is there another way?
Upvotes: 1
Views: 96
Reputation: 1750
No, its not necessary to have the source code unless you need to understand the methods of the class. You can use the compiled java class that will (usually) be available as a jar distribution.
Upvotes: 3
Reputation: 34424
If you just want to use that class file in your programm, you don't need the source code. Yo can straight away call that class methods. In IDS like eclipse when you type dot after object name of that class , even yo can see all the methods available for outside work. But yes if you want to understand the code of that class you need source code which you can get after decompilation of class too(if source code is not available)
Upvotes: 0
Reputation: 5064
You can get the compiled java class file and included that in your classpath. Normally it is good to have the source code with you because you can always reference if you are in doubt what actually the class methods do.
Upvotes: 0
Reputation: 103145
No, you do not need the source code, just the compiled class, which is typically distributed in jar files.
Upvotes: 2
Reputation: 8961
you'd typically have a jar file published by the author of the class you're going to use
Upvotes: 1