How to do standalone on-the-fly in-memory compilation with the eclipse compiler?
The eclipse compiler and its API have some significant advantages (especially beneficial to my application) over the one included in the JDK and so I'd like to use it. I have a standalone utility and I want to minimize its size and dependencies.
What is the way to get access to the eclipse compiler (minimum set of jar files and where to download them) and compile generated code on the fly in memory?
java eclipse
add a comment |
The eclipse compiler and its API have some significant advantages (especially beneficial to my application) over the one included in the JDK and so I'd like to use it. I have a standalone utility and I want to minimize its size and dependencies.
What is the way to get access to the eclipse compiler (minimum set of jar files and where to download them) and compile generated code on the fly in memory?
java eclipse
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27
add a comment |
The eclipse compiler and its API have some significant advantages (especially beneficial to my application) over the one included in the JDK and so I'd like to use it. I have a standalone utility and I want to minimize its size and dependencies.
What is the way to get access to the eclipse compiler (minimum set of jar files and where to download them) and compile generated code on the fly in memory?
java eclipse
The eclipse compiler and its API have some significant advantages (especially beneficial to my application) over the one included in the JDK and so I'd like to use it. I have a standalone utility and I want to minimize its size and dependencies.
What is the way to get access to the eclipse compiler (minimum set of jar files and where to download them) and compile generated code on the fly in memory?
java eclipse
java eclipse
edited Jan 9 '13 at 21:35
mentics
asked Jan 9 '13 at 0:17
menticsmentics
3,28732684
3,28732684
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27
add a comment |
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27
add a comment |
2 Answers
2
active
oldest
votes
Download ECJ by starting from this page, clicking on the latest release, then find and download the file ecj-[version].jar. For this, I’m using 4.2.1. Reference this jar in your classpath.
You use the org.eclipse.jdt.internal.compiler.Compiler
. Most things for the constructor have defaults available. You just give it a callback for the results in the form of an ICompilerRequestor. The below example uses a simple byte class loader to test the results. To do cascading compilation, you create a subclass of FileSystem, overriding the methods from INameEnvironment.
package test.eclipse.compiler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TestCompile {
static class ByteClassLoader extends ClassLoader {
private Map<String, byte> classMap;
public ByteClassLoader(Map<String, byte> classMap) {
super();
this.classMap = classMap;
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte bytes = classMap.get(name);
if (bytes == null) {
return super.findClass(name);
} else {
return defineClass(name, bytes, 0, bytes.length);
}
}
}
public static void compile(String code, String filename) {
ArrayList<Classpath> cp = new ArrayList<FileSystem.Classpath>();
Util.collectRunningVMBootclasspath(cp);
INameEnvironment env = new NameEnv(cp.toArray(new FileSystem.Classpath[cp.size()]), null);
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
ClassFile cf = result.getClassFiles();
HashMap<String, byte> classMap = new HashMap<String, byte>();
classMap.put("Test", cf[0].getBytes());
ByteClassLoader cl = new ByteClassLoader(classMap);
try {
Class<?> c = cl.loadClass("Test");
Method m = c.getMethod("test");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(),
new CompilerOptions(), requestor, new DefaultProblemFactory());
ICompilationUnit units = new ICompilationUnit { new CompilationUnit(code.toCharArray(), filename, null) };
compiler.compile(units);
}
public static void main(String args) {
compile("public class Test { public static void test() { System.out.println("Hello, world."); }}",
"Test.java");
}
}
Copied with permission from this blog post
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
add a comment |
Looks like you can find what you're looking for in the maven repository and use it with ant pretty easily.
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14226357%2fhow-to-do-standalone-on-the-fly-in-memory-compilation-with-the-eclipse-compiler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Download ECJ by starting from this page, clicking on the latest release, then find and download the file ecj-[version].jar. For this, I’m using 4.2.1. Reference this jar in your classpath.
You use the org.eclipse.jdt.internal.compiler.Compiler
. Most things for the constructor have defaults available. You just give it a callback for the results in the form of an ICompilerRequestor. The below example uses a simple byte class loader to test the results. To do cascading compilation, you create a subclass of FileSystem, overriding the methods from INameEnvironment.
package test.eclipse.compiler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TestCompile {
static class ByteClassLoader extends ClassLoader {
private Map<String, byte> classMap;
public ByteClassLoader(Map<String, byte> classMap) {
super();
this.classMap = classMap;
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte bytes = classMap.get(name);
if (bytes == null) {
return super.findClass(name);
} else {
return defineClass(name, bytes, 0, bytes.length);
}
}
}
public static void compile(String code, String filename) {
ArrayList<Classpath> cp = new ArrayList<FileSystem.Classpath>();
Util.collectRunningVMBootclasspath(cp);
INameEnvironment env = new NameEnv(cp.toArray(new FileSystem.Classpath[cp.size()]), null);
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
ClassFile cf = result.getClassFiles();
HashMap<String, byte> classMap = new HashMap<String, byte>();
classMap.put("Test", cf[0].getBytes());
ByteClassLoader cl = new ByteClassLoader(classMap);
try {
Class<?> c = cl.loadClass("Test");
Method m = c.getMethod("test");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(),
new CompilerOptions(), requestor, new DefaultProblemFactory());
ICompilationUnit units = new ICompilationUnit { new CompilationUnit(code.toCharArray(), filename, null) };
compiler.compile(units);
}
public static void main(String args) {
compile("public class Test { public static void test() { System.out.println("Hello, world."); }}",
"Test.java");
}
}
Copied with permission from this blog post
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
add a comment |
Download ECJ by starting from this page, clicking on the latest release, then find and download the file ecj-[version].jar. For this, I’m using 4.2.1. Reference this jar in your classpath.
You use the org.eclipse.jdt.internal.compiler.Compiler
. Most things for the constructor have defaults available. You just give it a callback for the results in the form of an ICompilerRequestor. The below example uses a simple byte class loader to test the results. To do cascading compilation, you create a subclass of FileSystem, overriding the methods from INameEnvironment.
package test.eclipse.compiler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TestCompile {
static class ByteClassLoader extends ClassLoader {
private Map<String, byte> classMap;
public ByteClassLoader(Map<String, byte> classMap) {
super();
this.classMap = classMap;
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte bytes = classMap.get(name);
if (bytes == null) {
return super.findClass(name);
} else {
return defineClass(name, bytes, 0, bytes.length);
}
}
}
public static void compile(String code, String filename) {
ArrayList<Classpath> cp = new ArrayList<FileSystem.Classpath>();
Util.collectRunningVMBootclasspath(cp);
INameEnvironment env = new NameEnv(cp.toArray(new FileSystem.Classpath[cp.size()]), null);
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
ClassFile cf = result.getClassFiles();
HashMap<String, byte> classMap = new HashMap<String, byte>();
classMap.put("Test", cf[0].getBytes());
ByteClassLoader cl = new ByteClassLoader(classMap);
try {
Class<?> c = cl.loadClass("Test");
Method m = c.getMethod("test");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(),
new CompilerOptions(), requestor, new DefaultProblemFactory());
ICompilationUnit units = new ICompilationUnit { new CompilationUnit(code.toCharArray(), filename, null) };
compiler.compile(units);
}
public static void main(String args) {
compile("public class Test { public static void test() { System.out.println("Hello, world."); }}",
"Test.java");
}
}
Copied with permission from this blog post
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
add a comment |
Download ECJ by starting from this page, clicking on the latest release, then find and download the file ecj-[version].jar. For this, I’m using 4.2.1. Reference this jar in your classpath.
You use the org.eclipse.jdt.internal.compiler.Compiler
. Most things for the constructor have defaults available. You just give it a callback for the results in the form of an ICompilerRequestor. The below example uses a simple byte class loader to test the results. To do cascading compilation, you create a subclass of FileSystem, overriding the methods from INameEnvironment.
package test.eclipse.compiler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TestCompile {
static class ByteClassLoader extends ClassLoader {
private Map<String, byte> classMap;
public ByteClassLoader(Map<String, byte> classMap) {
super();
this.classMap = classMap;
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte bytes = classMap.get(name);
if (bytes == null) {
return super.findClass(name);
} else {
return defineClass(name, bytes, 0, bytes.length);
}
}
}
public static void compile(String code, String filename) {
ArrayList<Classpath> cp = new ArrayList<FileSystem.Classpath>();
Util.collectRunningVMBootclasspath(cp);
INameEnvironment env = new NameEnv(cp.toArray(new FileSystem.Classpath[cp.size()]), null);
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
ClassFile cf = result.getClassFiles();
HashMap<String, byte> classMap = new HashMap<String, byte>();
classMap.put("Test", cf[0].getBytes());
ByteClassLoader cl = new ByteClassLoader(classMap);
try {
Class<?> c = cl.loadClass("Test");
Method m = c.getMethod("test");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(),
new CompilerOptions(), requestor, new DefaultProblemFactory());
ICompilationUnit units = new ICompilationUnit { new CompilationUnit(code.toCharArray(), filename, null) };
compiler.compile(units);
}
public static void main(String args) {
compile("public class Test { public static void test() { System.out.println("Hello, world."); }}",
"Test.java");
}
}
Copied with permission from this blog post
Download ECJ by starting from this page, clicking on the latest release, then find and download the file ecj-[version].jar. For this, I’m using 4.2.1. Reference this jar in your classpath.
You use the org.eclipse.jdt.internal.compiler.Compiler
. Most things for the constructor have defaults available. You just give it a callback for the results in the form of an ICompilerRequestor. The below example uses a simple byte class loader to test the results. To do cascading compilation, you create a subclass of FileSystem, overriding the methods from INameEnvironment.
package test.eclipse.compiler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.Compiler;
import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.eclipse.jdt.internal.compiler.util.Util;
public class TestCompile {
static class ByteClassLoader extends ClassLoader {
private Map<String, byte> classMap;
public ByteClassLoader(Map<String, byte> classMap) {
super();
this.classMap = classMap;
}
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte bytes = classMap.get(name);
if (bytes == null) {
return super.findClass(name);
} else {
return defineClass(name, bytes, 0, bytes.length);
}
}
}
public static void compile(String code, String filename) {
ArrayList<Classpath> cp = new ArrayList<FileSystem.Classpath>();
Util.collectRunningVMBootclasspath(cp);
INameEnvironment env = new NameEnv(cp.toArray(new FileSystem.Classpath[cp.size()]), null);
ICompilerRequestor requestor = new ICompilerRequestor() {
@Override
public void acceptResult(CompilationResult result) {
ClassFile cf = result.getClassFiles();
HashMap<String, byte> classMap = new HashMap<String, byte>();
classMap.put("Test", cf[0].getBytes());
ByteClassLoader cl = new ByteClassLoader(classMap);
try {
Class<?> c = cl.loadClass("Test");
Method m = c.getMethod("test");
m.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
}
};
Compiler compiler = new Compiler(env, DefaultErrorHandlingPolicies.exitAfterAllProblems(),
new CompilerOptions(), requestor, new DefaultProblemFactory());
ICompilationUnit units = new ICompilationUnit { new CompilationUnit(code.toCharArray(), filename, null) };
compiler.compile(units);
}
public static void main(String args) {
compile("public class Test { public static void test() { System.out.println("Hello, world."); }}",
"Test.java");
}
}
Copied with permission from this blog post
edited Jan 3 at 2:06
Community♦
11
11
answered Jan 9 '13 at 21:55
menticsmentics
3,28732684
3,28732684
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
add a comment |
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
The NameEnv class is missing. I found this (github.com/mentics/shen-on-java/blob/master/Shen-on-Java/src/…) but it has a bunch of dependencies on other parts of the app. Do you have a simple implementation of it that does the bare necessities?
– ccleve
Jan 2 at 20:34
add a comment |
Looks like you can find what you're looking for in the maven repository and use it with ant pretty easily.
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
add a comment |
Looks like you can find what you're looking for in the maven repository and use it with ant pretty easily.
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
add a comment |
Looks like you can find what you're looking for in the maven repository and use it with ant pretty easily.
Looks like you can find what you're looking for in the maven repository and use it with ant pretty easily.
answered Jan 9 '13 at 1:04
hd1hd1
24.9k35769
24.9k35769
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
add a comment |
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
Thanks! Is there somewhere that tells how to use it to compile a single class in memory? I'll more clearly indicate that in the question.
– mentics
Jan 9 '13 at 7:16
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
I'd write the string to a file ending in .java and send that to ECJ.
– hd1
Jan 9 '13 at 7:28
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
No. This is a performance critical situation. Needs to be as fast as possible.
– mentics
Jan 9 '13 at 20:19
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14226357%2fhow-to-do-standalone-on-the-fly-in-memory-compilation-with-the-eclipse-compiler%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't know if this is what you are looking for, but it was the first hit I got from googling "eclipse compiler": eclipse.org/jdt/core/index.php
– Code-Apprentice
Jan 9 '13 at 0:22
That's kind of what I'm talking about but notice that is much more than just the compiler.
– mentics
Jan 9 '13 at 0:27