J
Jesper Sahner
Hi!
I want to create a dynamic class "on the fly". For this I use:
String[] s = {"Myclass.java"};
(new com.sun.tools.javac.Main()).compile(s);
This works fine. The code reads the .java-file and creates the
..class-file. No problem.
Now I wonder if the same thing can be done without using external
files. The source-code for the .java-file could be held in e.g. a
String-object, and the byte-code as a result of the compilation could
be parsed to a ClassLoader-object.
However I don't how to do this, but I think it must be possible.
Any ideas?
Regards,
Jesper
I want to create a dynamic class "on the fly". For this I use:
String[] s = {"Myclass.java"};
(new com.sun.tools.javac.Main()).compile(s);
This works fine. The code reads the .java-file and creates the
..class-file. No problem.
Now I wonder if the same thing can be done without using external
files. The source-code for the .java-file could be held in e.g. a
String-object, and the byte-code as a result of the compilation could
be parsed to a ClassLoader-object.
However I don't how to do this, but I think it must be possible.
Any ideas?
Regards,
Jesper