Results 1 to 3 of 3

Thread: runtime compiler!

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question runtime compiler!

    I found a compiler in run-time!

    but I don't know how does it work?

    it is a class named jcompiler in util package in shine pattern!

    who can help me?

    I found it at :
    http://sourceforge.net/projects/shine-enterpris/files/
    Last edited by sally; 07-11-2010 at 09:11 PM. Reason: incomplete message

  2. #2
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation well done

    i enjoy doing this
    so follow my code and you enjoy this too.

    filename :Engine .java
    ---------------------
    Code:
    package mypackage;
    import org.j2sos.shine.jshooter.Application;
    import org.j2sos.shine.maplet.Maplet;
    public class Engine extends Maplet {
    public String name;
    public String body;
    public void learning() {
    try {
    new Memory().addMethod("public String " + name +
    "() throws Exception {" + body + "}");
    out.println("Learned.");
    } catch (Exception e) {
    out.println(e.getMessage());
    }
    }
    public void request() {
    try {
    Application app = new Application();
    app.setObject(new Logic());
    out.println(app.invokeMethod(name));
    } catch (Exception e) {
    out.println(e);
    }
    }
    }

    file name :Logic.java
    -----------------------------
    Code:
    package mypackage;
    public class Logic {
    public String hello() throws Exception {
    return "hello user!";
    }

    file name : Memory.java
    --------------------------------
    Code:
    package mypackage;
    import org.j2sos.shine.util.JCompiler;
    public class Memory extends JCompiler
    {
    public void addMethod(String body)throws Exception{
    new
    Memory().addCommandToClassBodyInWindowsRuntime("mypackage.Logic",body);
    }
    }

    file name : index.jsp
    -------------------
    Code:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <H1>Virtual Human</H1>
    <P>
    <a href="Learning.jsp">Learning.jsp</a>
    </P>
    <P>
    <a href="Request.jsp">Request.jsp</a>
    </P>
    file name : Learning.jsp
    -----------------------
    Code:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <H1>Virtual Human</H1>
    <form action="servlet/mypackage.Engine" method="get">
    <P>Method Name:
    <input type="text" name="name"/>
    </P>
    <P>Body:</P>
    <P>
    <textarea cols="40" rows="20" name="body"></textarea>
    </P>
    <P>
    <input type="submit" value="Submit"/>
    </P>
    </form>

    file name : Request.jsp
    ----------------------
    Code:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <H1>Virtual Human</H1>
    <form action="servlet/mypackage.Engine" method="get">
    <P>Method Name:
    <input type="text" name="name"/>
    </P>
    <P>
    <input type="submit" value="Submit"/>
    </P>
    </form>

    replay me if there was any problem
    or refer to shine doc

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking re: well done

    wow!!! thank you I'll try it! and if had questions I'll ask you!

    thanks a lot!

Bookmarks

Posting Permissions

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