Results 1 to 2 of 2
  1. #1
    ~'s Avatar
    ~ is offline Member
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Question Dynamically interpreting/importing code/classes

    Hi,

    I wish to make a program that is capable of importing classes that have not been included or referenced in the program itself.

    I would also like to know if Java offers some way to interpret code from say, an input text box or a file, for on-the-fly execution, either in plain text or bytecode form.

    With proper interpretation I mean to even declare completely new variables, etc., at run time.

    I want to make a program that allows the user to specify a list of Java commands and the program loads the code and/or classes on demand, to test any APIs easily and to test different exceptions and results, etc.

    Please point me to the most appropriate API references to do this, and a simple example or rationales if you consider it necessary.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    I wish to make a program that is capable of importing classes that have not been included or referenced in the program itself.

    "Importing classes"? Do you mean you want to use instances of classes you mention by name rather than declaring them in the source code? That's what Class.forName() and the associated java.lang.reflect package let you do.

    I would also like to know if Java offers some way to interpret code from say, an input text box or a file

    There are interpreters for any number of languages implemented in Java. Have you tried Google?

    If your focus is interpreting Java source code your best bet might be BeanShell.

Similar Threads

  1. Importing classes in upper directory.
    By PrinceSendai in forum New To Java
    Replies: 2
    Last Post: 02-25-2011, 05:28 AM
  2. Importing Picture into Java Code
    By swimmy101 in forum New To Java
    Replies: 1
    Last Post: 02-12-2009, 09:48 AM
  3. importing other classes or using a Jar
    By xhane in forum New To Java
    Replies: 3
    Last Post: 01-31-2009, 06:20 AM
  4. Need help with importing classes
    By Deathmonger in forum New To Java
    Replies: 3
    Last Post: 02-07-2008, 11:03 AM
  5. Importing classes
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-06-2007, 03:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •