Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Compiler Needed Urgently
Compiler Needed Urgently [message #199148] Mon, 21 March 2005 12:27 Go to next message
Eclipse UserFriend
Originally posted by: robin_drew.hotmail.com

For a project i am working on, i urgently need a compiler can take a
String containing the java file definition (package + imports + class),
and output a byte[] containing the compiled code.

I don't believe the source to javac is available to developers (or is
it?). The only other possibilities i have are to write the code to the
file system and invoke javac via a Runtime.exec() which is unacceptable.

I have investigated the Kopi compiler but this is now defunct and although
it worked for 1.4.2 it does not work for version 1.5

I have investigated eclipse but am a bit concerned at the time it may take
to navigate their core code and find the classes necessary.

______________________________________
At the top level all i need is the following method!

byte[] compile(String javaCode);



Any suggestions gladly accepted.
Re: Compiler Needed Urgently [message #199156 is a reply to message #199148] Mon, 21 March 2005 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Look at class: org.eclipse.jdt.internal.compiler.batch.Main.
It invokes the compiler and receives the byte[] in memory through requestor
API.
That should be fairly easy to adapt to meet your needs.

"Robin Drew" <robin_drew@hotmail.com> wrote in message
news:3fc84cfd0c0212215eb2b8a5785e5350$1@www.eclipse.org...
> For a project i am working on, i urgently need a compiler can take a
> String containing the java file definition (package + imports + class),
> and output a byte[] containing the compiled code.
>
> I don't believe the source to javac is available to developers (or is
> it?). The only other possibilities i have are to write the code to the
> file system and invoke javac via a Runtime.exec() which is unacceptable.
>
> I have investigated the Kopi compiler but this is now defunct and although
> it worked for 1.4.2 it does not work for version 1.5
>
> I have investigated eclipse but am a bit concerned at the time it may take
> to navigate their core code and find the classes necessary.
>
> ______________________________________
> At the top level all i need is the following method!
>
> byte[] compile(String javaCode);
>
>
>
> Any suggestions gladly accepted.
>
Re: Compiler Needed Urgently [message #199165 is a reply to message #199148] Mon, 21 March 2005 12:42 Go to previous message
Eclipse UserFriend
There is Javassist from JBoss. Not sure whether it supports 1.5 yet.

John.

Robin Drew wrote:
> For a project i am working on, i urgently need a compiler can take a
> String containing the java file definition (package + imports + class),
> and output a byte[] containing the compiled code.
>
> I don't believe the source to javac is available to developers (or is
> it?). The only other possibilities i have are to write the code to the
> file system and invoke javac via a Runtime.exec() which is unacceptable.
>
> I have investigated the Kopi compiler but this is now defunct and
> although it worked for 1.4.2 it does not work for version 1.5
>
> I have investigated eclipse but am a bit concerned at the time it may
> take to navigate their core code and find the classes necessary.
>
> ______________________________________
> At the top level all i need is the following method!
>
> byte[] compile(String javaCode);
>
>
>
> Any suggestions gladly accepted.
>
Previous Topic:keybindings in 3.1M5: ctrl-w hardcoded?
Next Topic:Timing problem with variables view show types action.
Goto Forum:
  


Current Time: Fri Jul 18 20:38:45 EDT 2025

Powered by FUDForum. Page generated in 0.03814 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top