Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: Joe on June 16, 2006, 02:16:42 AM

Title: [Java] Loading class files?
Post by: Joe on June 16, 2006, 02:16:42 AM
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. =/
Title: Re: [Java] Loading class files?
Post by: iago on June 16, 2006, 10:18:29 AM
This isn't a tutorial. 
Title: Re: [Java] Loading class files?
Post by: iago on June 16, 2006, 01:23:17 PM
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. 
Title: Re: [Java] Loading class files?
Post by: Joe on June 16, 2006, 07:54:58 PM
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