Compile From String [message #201089] |
Fri, 15 April 2005 16:04  |
Eclipse User |
|
|
|
Originally posted by: mmacfadden.redoaksw.com
All,
I am using JET to create some Java code. From this code I need to
create a Java class file. This class file is likely to be written to a
file that is not in the Eclipse workspace. The is no need to have a
source (.Java) file every be written to the hard drive. From JET I get
a string that represents a Java source file.
What I am wondering if there is a way for me to use the eclipse Java
compile to compile this string and write a class file? I see where I
can call the org.eclipse.jdt.internal.compiler.batch.Main class to
compile things, but this seems like it would require first generating a
..Java file, then doing the compilation, then deleting the source file.
Is there anyway I can create a class file directly from the String (or
char[]) that represents the Java source. Thanks.
Regards,
Mike MacFadden
|
|
|
Re: Compile From String [message #202350 is a reply to message #201089] |
Tue, 03 May 2005 06:46  |
Eclipse User |
|
|
|
The Eclipse compiler kernel doesn't need files in or out. It manipulates
ICompilationUnit (wrapper for a char[]), and produces IClassfile (wrapper
for byte[]).
So you could customize the Main front-end to meet your need; and compute a
different list of ICompilationUnit than currently.
FYI, org.eclipse.jdt.internal.compiler.batch.CompilationUnit already
supports being associated with custom source in memory (and only lazily goes
to disk to extract from given source file). You just need to create these
units from your strings, and pass them to compiler.
"Michael MacFadden" <mmacfadden@redoaksw.com> wrote in message
news:d3p78g$uki$1@news.eclipse.org...
> All,
>
> I am using JET to create some Java code. From this code I need to
> create a Java class file. This class file is likely to be written to a
> file that is not in the Eclipse workspace. The is no need to have a
> source (.Java) file every be written to the hard drive. From JET I get
> a string that represents a Java source file.
>
> What I am wondering if there is a way for me to use the eclipse Java
> compile to compile this string and write a class file? I see where I
> can call the org.eclipse.jdt.internal.compiler.batch.Main class to
> compile things, but this seems like it would require first generating a
> .Java file, then doing the compilation, then deleting the source file.
>
> Is there anyway I can create a class file directly from the String (or
> char[]) that represents the Java source. Thanks.
>
> Regards,
> Mike MacFadden
|
|
|
Powered by
FUDForum. Page generated in 0.02704 seconds