Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Building java classes dynamically

Options
  • 17-06-2009 1:52pm
    #1
    Closed Accounts Posts: 155 ✭✭


    Afternoon all.

    I'm trying to figure out a way to build java classes dynamically.

    An overview of the problem follows:

    I am building a UI for a tool which is currently command line only and interaction will happen using this tools commands. SQL isn't a option for a reasons I won't bore anyone with.

    I can run a command which will give me a list of tables and using this I can get data on each table (when I query a table I get a list of attributes for the table and all the data in the table). Using this I want to build a class dynamically (all the attributes will be String variables) and afterwards create the objects.

    Any ideas or advice on dynamic class creation? I found a reference to Javassist but am wondering about other possibilities and whether anyone has experience with any of the options.

    Cheers


Comments

  • Registered Users Posts: 981 ✭✭✭fasty


    Why not just have a class that uses containers of some kind for the attributes and data and an interface to access the data?


  • Registered Users Posts: 5,618 ✭✭✭Civilian_Target


    Why would you do that?

    I guess you know what the output should look like... so call the command, and pipe the input into Java. Parse what you want out of it from there, using Scanner.


  • Closed Accounts Posts: 155 ✭✭cooperla


    Thanks for the comments guys.

    I haven't used java much so I'll have to take a bit of time to research your suggestions.

    Cheers,


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Look at the reflection classes. They will do what you want.


Advertisement