News:

Holy shit, it's 2018 2019 2020 2021 2022 2023 2024, and the US isn't a fascist country! What a time to be alive.

Main Menu

[Java] Loading class files?

Started by Joe, June 16, 2006, 02:16:42 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Joe

Remember in JavaOp1, how there was a folder of .class files for each packet and they were dynamically loaded on startup? How was that done? I tried reading the code but it was *really* overintwined. =/
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.


iago


iago

Ok, it's in the right forum.  I still don't like how the question was asked, but I'll give you a hint anyways:

Look in the file: javaop/src/commands/util/DocumentFlags.java

All you need to know is in there. 

Joe

RemoteCommandInterface r = (RemoteCommandInterface) Class.forName("commands." + thisFile).newInstance();

So, implement an interface that the bot is aware of, and then use Class.forName(pkgName " + "." + className + ".class").newInstance(); and typecast it back to that interface? Sweet. I was just looking at the packet stuff and forgot about the commands.

PS: Sorry for insulting your coding style with the overintwined comment at the beginning. =p
Quote from: Camel on June 09, 2009, 04:12:23 PMI'd personally do as Joe suggests

Quote from: AntiVirus on October 19, 2010, 02:36:52 PM
You might be right about that, Joe.