javac

javac @<opiton_file> and encoding

有些话、适合烂在心里 提交于 2019-12-11 05:11:12
问题 I'm trying to compile some java files on my computer under Windows 7 in french; and I thing I have some trouble with file endoding... In a first step, I'm generating a list of the file to compile: dir src\*.java /B/S > javasrc.tmp~ Which will wrote in the file "javasrc.tmp~" line by line the full path of java file (recursivly) of the directory src. In my case I have : C:\Users\Alexandre\Développement\Java\src\testA.java C:\Users\Alexandre\Développement\Java\src\testB.java [...] (Note that

Why is javac's -cp option case sensitive, but java's -cp option not?

妖精的绣舞 提交于 2019-12-11 02:49:45
问题 I've noticed that case sensitivity for javac and java options seem to vary. For instance: Case sensitive javac command option? -cp Yes -sourcepath Yes -d No Case sensitive java command option? -cp No As an example of case sensitivity for these four options, take the following folder structure: project \ src \ Main.java \ subf \ Sub.java \ bin \ Main.class \ subf \ Sub.class Main.java, which shows the Sub class being used - class Main { public static void main(String[] args) { subf.Sub.method(

How to suppress “unknown enum constant” warnings?

我怕爱的太早我们不能终老 提交于 2019-12-11 00:53:58
问题 The Checkers Framework references java.lang.annotation.ElementType.TYPE_USE which was added in JDK8. When I use it under JDK7, I get the following warning: unknown enum constant java.lang.annotation.ElementType.TYPE_USE This is a reasonable warning, but how do I suppress it for cases I believe are harmless ? 回答1: It turns out there is no such thing as a harmless unknown enum constant. Once I got past the compiler warnings, I ran into exceptions at runtime: java.lang.ArrayStoreException: sun

Running J2EE Eclipse in a VM - Unable to find a javac compiler

点点圈 提交于 2019-12-11 00:27:27
问题 Kinda new posting up questions here so bear with me. I had to install a XP VM recently in order to run a program that required use of an Oracle 10g client. I setup my tomcat server and when I went through the directory and started the .jsp file, I got this error 2011-02-22 09:13:01,291 ERROR (org.apache.jasper.compiler.Compiler:394) - Javac exception Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK Weird thing is I

Compiling loops in Java

霸气de小男生 提交于 2019-12-10 23:55:47
问题 As I can see from JVM specification this code: void spin() { int i; for (i = 0; i < 100; i++) { ; // Loop body is empty } } should be compiled into: 0 iconst_0 1 istore_1 2 goto 8 5 iinc 1 1 8 iload_1 9 bipush 100 11 if_icmplt 5 14 return where condition check if_icmplt is after the loop body, but when I compile it myself and view with javap, I see: 0: iconst_0 1: istore_1 2: iload_1 3: bipush 100 5: if_icmpge 14 8: iinc 1, 1 11: goto 2 14: return and loop condition is before the cycle body.

Does specifying the encoding in javac yield the same results as changing the active code page in Windows CMD and then compiling directly?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 21:47:25
问题 I am trying to compile a piece of Java code in Windows CMD using Windows-1250 encoding, and I can't seem to get the -encoding option to work right. The compiler just doesn't seem to use the specified encoding unless there are illegal characters, in which case it just displays the error message. Otherwise it uses the active code page anyway. In particular, I am trying to display a string containing Albanian characters, specifically 'ë'. The string I need to display is as follows: Hëllë Wërld

Ant build fails with no visible errors

匆匆过客 提交于 2019-12-10 19:06:44
问题 EDIT: I ended up setting up the whole project in Eclipse and was able to get it to build. I'm not sure why this problem occurred and hopefully I'll never have to find out. I'm having a problem where my build is reporting "BUILD FAILED" without reporting any errors. I'm building a large application of a lot of old code which I now have the joy of modifying. Most of the other developers have set up their builds with Eclipse, but I'm trying to build it through the existing build.xml files. After

Java ant script does not show warnings

﹥>﹥吖頭↗ 提交于 2019-12-10 17:34:39
问题 I have a 1.4 java code and I want to compile it with a 1.5 compiler because I would like to see all warning messages. I added the -Xlint option to javac, but it seems there were no changes in the output, but I know there is at least a couple of warnings in the code. I added these two lines to my ant script's compile target tag: <compilerarg value="-Xlint:all"/> <compilerarg line="-Xmaxwarns 10000"/> Thank you for your answers. 回答1: You have used value and line attributes at the same time.

Why does the Java compiler add visibility bridge methods for public methods defined in package-private super types?

空扰寡人 提交于 2019-12-10 17:21:29
问题 I am wondering why the Java compiler would add a bridge method for the foo method here: public class Outer { class SuperClass { public void foo() { } } public class SubClass extends SuperClass { } } The foo method is compiled to be public in the SuperClass type. Nevertheless, the SubClass method redefines the method as a bridge to the very same method. I wonder why this bridge is necessary. 回答1: The rational for adding this bridge method is a corner-case in the Java reflection API which would

Maven 3: How to exclude generated sources from Xlint check?

孤街醉人 提交于 2019-12-10 16:46:12
问题 We only allow java source code without Xlint errors. However, when sources are generated by third party tools, this is not practical. Examples of generated sources in our use-case are: JFlex, JavaCC, JAXB and annotation processors. So the question is: how to exclude the generated sources from the Xlint checks? (see current configuration below) <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration combine.self="override"> <source>${java.version}<