CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    587

    dynamically executing java code

    if a user submits their .java file to my online website, how could i make my java application automatically execute this code?

    my java application runs on an aplet, and the things users submit are computer players for a game competition

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: dynamically executing java code

    If they are submitting .java files (source code), you need to compile it before you can run it.

    Check out the Compiler API - see JSR 199: Programmatic Compiling and Programmatic Compilation.

    Once you've got the code compiled, you should be able load the class files with a class loader and run it in your own application.

    Sounds easy, doesn't it? I bet it isn't...

    The cheapest, fastest, and most reliable components of a computer system are those that aren't there...
    G. Bell
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: dynamically executing java code

    This classloaders tutorial shows an example of using classloaders by writing a sample program that compiles and runs code on the fly. This may just provide the basis of what you want.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured