How to do ReUsability in Java? Or use a JAR file?

m-jeri

A Nobody.
Skilled
Hi All.

So lately i been into Java things. :). Skill building. :(. I dont know anything about Java. Everything I am doing like what i will do in C++ or .NET.

So I want to know about Re usability in Java. I know about DLL's and all. but in Java how does it work.
I understand there is a way to include the source and do it. but is that the actual way? On reading more I read about Jar files and how I can import it.

So in my ADF project. I added a JAR file with a single class that will validate a log in. When i try to import the file it does. but as i read in some article i cant add that into project. But when i try to import the class in my ADF class. it compiles without any error. So i am guessing it works.

Can anyone tell more about this. No clue here.

Thanks
 
You will have to add the jar in the class path for the app and then import the required classes to use. Same when running the app. If you have a dependency jar, you need to add it into the classpath.
 
Ok. Updates for this.

I have tried adding it as a external dependency and as like a resource, through resource palette. I can import fine, Access the code, compile and all. But when I deploy to say android simulator, when i am running the test app it will give me some bindings error.
The code is not usable. :(

So in the end, I just had to export the class itself and use. But that is not a re usability now. is it? I am noob at Java so please correct me. Using JDevloper with Mobile ADF.
 
@OP
For ex, i created "eating" module. Since i need it in many places, i created a JAR of it.
Now i need that JAR in Human and Animal modules. Just put your JAR file in classpath, access the method. That's it!

End of the day, even JAR files is nothing but collection of class files. But not to handle by yourself. JVM will handle that thing. All you need to check is, that whether tha JAR file you are creating is error free.
 
Back
Top