javac

Set ant bootclasspath: JDK 1.7 has a new javac warning for setting an older source without bootclasspath

删除回忆录丶 提交于 2019-12-06 18:36:41
问题 How do I set the ant bootclasspath in conjunction with -source 1.5 -target 1.5? How can this not be a hardcoded path to the 1.5 JDK? Can I set an environment variable to bootclasspath similar to how JAVA_HOME can be used from ant? Ideally I would like to do something like set an environment variable or pass an argument to ant. 回答1: Here's an illustration of how you might fetch the Java 5 boot classes location from an environment variable, then use it. First, set the environment variable - say

How to produce code in Java 11, but target Java 8 and above?

余生颓废 提交于 2019-12-06 17:27:52
问题 I am working on a small library and for obvious reasons I would like to produce code using all the Java 11 features (except modules I guess for now), but I would like the library to be compatible with Java 8 and above. When I try this: javac -source 11 -target 1.8 App.java I get the following message: warning: source release 11 requires target release 11 ...and when I look at the byte code I see that the version of the class is 0x37 (Java 11): $ xxd App.class 00000000: cafe babe 0000 0037 ...

gcc or javac slow at first startup

南楼画角 提交于 2019-12-06 15:20:15
Can anyone explain why in linux when I start gcc or javac after some time of inactivity it takes a while for them to start. Subsequent invocations are way faster. Is there a way to ensure quick startup always? (This requirement may seem strange, but is necessary in my case). Ubuntu by the way. Most likely, it's the time it takes for code pages to fault in. There are a few ways to avoid this delay if you really have to. The simplest would be to run gcc periodically. Another would be to install gcc to a RAM disk. Another approach would be to make a list of which files are involved and then write

Hosting the Java compiler in an applet or in Google AppEngine?

白昼怎懂夜的黑 提交于 2019-12-06 15:04:00
Searching the web I've found that the Javac compiler is written in Java, and I also peeked at the source on Sun's site. The source is quite big and I couldn't make any headway on it. Also the Eclipse project has a compiler embedded inside, but who could touch its source code ;-). So I thought I'd throw a couple of questions your way: Could the Java compiler be hosted in an Applet? Could the Java compiler be made to work on GAE, with dynamic loading of the resulting class files from the datastore? Yes, the compiler as such is really just a normal Java application (except that it usually brings

How do I find the type declaration of an identifier using the Java Tree Compiler API?

对着背影说爱祢 提交于 2019-12-06 12:45:31
I have the name of a variable/identifier, say, x , and the JCCompilationUnit and Scope . Is there a way to find the type of x ? public Symbol getSymbol(CompilationUnitTree cut, JCStatement stmt, List<JCExpression> typeParams, Name varName, List<JCExpression> args) { java.util.List<Type> typeSyms = getArgTypes(typeParams, cut, stmt); java.util.List<Type> argsSyms = getArgTypes(args, cut, stmt); final Scope scope = getScope(cut, stmt); Symbol t = contains(scope, typeSyms, varName, argsSyms); //first lookup scope for all public identifiers TypeElement cl = scope.getEnclosingClass(); while (t ==

JavaCompiler not compiling files properly

杀马特。学长 韩版系。学妹 提交于 2019-12-06 12:04:22
问题 I am trying to get used to the JavaCompiler and trying to compile programs with it, I can successfully compile programs that comprises of single file but when im trying to compile projects with multiple files. I get errors on compiling files that implement other classes and where ever the class uses a method from the implemented class. Here is the code that I am using to compile the java code private final String directoryForBin = "C:/TempBINfolder/bin"; public List doCompilation(String

Compiler does not find other classes in the same directory

筅森魡賤 提交于 2019-12-06 10:53:30
问题 I wrote a Java program that has 3 classes. When, I use javac, I am getting errors whenever my main class attempts to interact with the other classes. Is there anything special that I need to do? I am just calling javac Main.java. Any help would be greatly appreciated. Edit: DFA myDFA = new DFA(); String test = args[0]; if(myDFA.accept(test)) and the error is: Main.java:19: cannot find symbol symbol: class DFA location class dfa.Main I have 3 of those errors 回答1: Yes, you need to specify the

Rejecting re-init on previously failed class error when loading a Class with dalvikvm

本小妞迷上赌 提交于 2019-12-06 08:57:58
I am trying to use Terminal IDE on Lollipop 5.1.1. Using a Samsung E7 device, a mod version of Terminal IDE is provided by someone on XDA here: http://forum.xda-developers.com/showthread.php?t=1340852&page=7 I tried to use javac script in that mod but it gave an unsatisfied link error, saying that: $ javac java.lang.UnsatisfiedLinkError: org.apache.harmony.security.fortress.Services at org.apache.harmony.security.fortress.Engine.getServices(Engine.java:158) at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:137) at java.security.cert.CertificateFactory.getInstance

Java 8 Incompatible Types

对着背影说爱祢 提交于 2019-12-06 08:53:31
问题 Here's the simple code import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class SimpleTest { public static void main(String[] args) { final ArrayList<Map<String, Object>> maps = newArrayList( createMap("1", "a", Collections.EMPTY_MAP, Collections.EMPTY_MAP), createMap("2", "b", Collections.EMPTY_MAP, Collections.EMPTY_MAP), createMap("3", "c", Collections.EMPTY_MAP, Collections.EMPTY_MAP) ); System.out.println(" maps = " + maps); }