incorporate java code
I have no idea where to start with this! I might even be posting in the wrong forum. Anyway - here's my problem.
I have algorithms which I have written. They all all perform a task, but have different approaches to it. They all implement an interface I have written.
Now. I want to design a GUI where the user selects the algorithm to use and gives it some parameters. Not that difficult really.
The difficult part (well - it may be simple but I don't know how to do it) I want other people to be able to write their own algroithm and then use my software tool to run it for them. I don't know if I would either need the .java source code and complile it, or the compiled .class file. And how would I then get this into my program?
I want there to be a drop down combo box which contains the algorithms I have written. And then a button which they can click to browse to locate their file (either the .java or .class - whichever I need). If the code implements my interface properly than I want to add their algoriythm name to the list in the drop down box.
If I have not given enough details or it doesn't make sense please ask some questions.
Any help on where to start would be great, maybe a couple of resources which detail this kind of thing where I can teach myself. Does this process have a name?
Thanks
[1364 byte] By [
sparky132a] at [2007-10-2 10:16:05]

> I have algorithms which I have written. They all all
> perform a task, but have different approaches to it.
> They all implement an interface I have written.
What do these algorithms do? Did you write them yourself or purchase them?
> I want other people to be
> able to write their own algroithm and then use my
> software tool to run it for them. I don't know if I
> would either need the .java source code and complile
> it, or the compiled .class file. And how would I
> then get this into my program?
Other people could write their own algorithm and print it out and send it to you. When you get it you could read it and create the source code and class files to use the software tool to run.
>
> Now. I want to design a GUI where the user selects
> the algorithm to use and gives it some parameters.
> Not that difficult really.
>
> The difficult part (well - it may be simple but I
> don't know how to do it) I want other people to be
> able to write their own algroithm and then use my
> software tool to run it for them. I don't know if I
> would either need the .java source code and complile
> it, or the compiled .class file. And how would I
> then get this into my program?
>
If each class is uniquely named and each class will live in a single directory then basically all you need to do is have your class path pointing at the directory.
Then you use Class.forName() to load it - being very careful to use the interface to refer to (not the actual class name - since you can't do that anyways.)
If you want to reload the class then it gets more complicated. You would have to use a class loader.
> Other people could write their own algorithm and print it out and send it to you. When you get it you could read it and create the source code and class files to use the software tool to run.
What?! Print it out?! No!! I really don't think you understand my problem.
My algorithms implement OVSF Code Assignment in Wireless Networks (Related to 3G Mobile phone networks). I have implemented a couple of algorithms I have found in literature as psuedo-code and also written my own.
The idea of this tool is to run these different algorithms and analyse their performance. And I want people to be able to write their own algorithms and then point my tool at it and run it. Hence the need for loading their java files.
I think the Class and ClassLoader are more in the direction I want. I will look into that.
Thanks