javac

How do I pass javac multiple command-line arguments, some of which include colon, without breaking Maven release plugin?

自闭症网瘾萝莉.ら 提交于 2019-12-01 06:36:32
I want to make my Maven build fail when I forget to declare serialVersionUIDs in a Serializable class. With javac , that's easy: $ javac -Xlint:serial -Werror Source.java Directly translating that to Maven doesn't work: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <compilerArgument>-Xlint:serial -Werror</compilerArgument> </configuration> </plugin> The compilerArgument is quoted, so javac receives only one argument, containing -Xlint:serial -Werror , instead of -Xlint:serial and -Werror as separate

Java CRTP and Wildcards: Code compiles in Eclipse but not `javac`

丶灬走出姿态 提交于 2019-12-01 06:19:36
Sorry for the vague title. I have this piece of code which compiles on Eclipse Juno (4.2) but not javac (1.7.0_09): package test; public final class Test { public static class N<T extends N<T>> {} public static class R<T extends N<T>> { public T o; } public <T extends N<T>> void p(final T n) {} public void v(final R<?> r) { p(r.o); // <-- javac fails on this line } } The error is: Test.java:13: error: method p in class Test cannot be applied to given types; p(r.o); ^ required: T found: N<CAP#1> reason: inferred type does not conform to declared bound(s) inferred: N<CAP#1> bound(s): N<N<CAP#1>>

(JAVA) Use Command Prompt to create .jar file from multiple .class files

拜拜、爱过 提交于 2019-12-01 04:21:30
I have written a .java file, called Main.java, and have compiled it using the javac in the Windows Command Prompt. The compiler is creating multiple .class files (called Main.class, Main$1.class, & Main$2.class--presumably because I have anonymous inner classes in my Main.java file). I am trying to create a runnable .jar file so I can double click a shortcut to run this application (it is a Java Swing application), but I am unsuccessful when I navigate to the directory of the three class files and type: jar cfv file.jar Main.class Main$1.class Main$2.class The Command Prompt then outputs this

How does the java compiler find the class files whereas the classpath is not set to the jdk path?

可紊 提交于 2019-12-01 04:00:25
I'm trying to look under the hood about java compilation. So I put my IDE away and started using MS-DOS command-line... I created a simple project, as described in the tree below : SampleApp |____**src** |_____pack |______Sample.java |____**classes** This is the Sample.java source code : public class Sample { private String s = new String("Hello, world"); public Sample(){ System.out.println(s); } } I just want to compile this class, so I used the javac command : prompt\SampleApp\src>javac -d ..\classes -sourcepath . pack\Sample.java All works fine, but i didn't expect that because I deleted my

Set Java compiler compliance level

爱⌒轻易说出口 提交于 2019-12-01 03:16:16
I need to compile a Java program on the command line, and I am trying to set the compiler level to a lower one (1.6). I tried like this but it didn't work: javac -1.6 Hello.java Use -source and -target options: javac -target 1.6 -source 1.6 Hello.java Nayuki Use: javac -source 1.6 -target 1.6 Hello.java This information comes from running javac -help : Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output

How does the java compiler find the class files whereas the classpath is not set to the jdk path?

谁说我不能喝 提交于 2019-12-01 01:26:56
问题 I'm trying to look under the hood about java compilation. So I put my IDE away and started using MS-DOS command-line... I created a simple project, as described in the tree below : SampleApp |____**src** |_____pack |______Sample.java |____**classes** This is the Sample.java source code : public class Sample { private String s = new String("Hello, world"); public Sample(){ System.out.println(s); } } I just want to compile this class, so I used the javac command : prompt\SampleApp\src>javac -d

【javac添加python 列表特性5】修改openJDK的Javac,使得支持List k...

早过忘川 提交于 2019-11-30 20:12:34
先把附件和测试文件发上来: Javac.rar (我使用的是JDK1.7) 经过前一阶段的学习,对javac前端Parser阶段已经有了足够的理解,要使javac支持类似python的列表语法: List k=[1,'a',[2,3],"abc", new Object()]; 这种语法的特征是: List 直接来源于java.util.*; 初始化时使用的是[]; 列表支持多种类型(基本和引用)混合; 支持列表的嵌套; 实现 的想法是: Java里面已经有了如下可以支持的语法: List k=new ArrayList(Arrays.asList(1,'a',"abc")); 所以只需要在Parser阶段,在VariableInitilizer里面加上识别[]的语句,并且把后面[]的内容改成Java已经支持的语法:new ArrayList(Arrays.asList())即可。 实现的具体方法: 继承JavacParser类和Scanner类,以便进行扩展。 覆写JavacParser的 variableInitializer,如果有LBRACKET,则return listInitializer(); 在listInitializer()里面可以先构造一段String newbuf="ArrayList(Arrays.asList( '[]里面的内容' ))"的代码

【javac添加python 列表特性4】Idea:希望Javac能支持的Python列表特性

自作多情 提交于 2019-11-30 20:12:21
对于python的list,相信用过的人都知道有好些很cool的功能,我希望能把这些功能加入到java里面去。 我希望java能够支持一下的Python特性: public class Main{ //list define List k=[]; List k1=['1',2,3]; List k2=[k1,k2]; List<Integer> kk=[1,2,3,new Integer(4)]; //list assignment k=[1,'2',3,4,"a","b",6]; k1=k; //list get element int a=k[2]; a=k[-1]; k=k[0:-1]; k=k[2:]; k=k[:2]; k=k[::-1]; //reverse array k=k[1:5:2];// from element 1 to element 5, increase step is 2 //advanced assignment list k3=[i*i for i in k if i <3]; //add k=k+k1; //get length k.length(); //convert k.toString(); //toArrayList k.toarraylist() } 这样,需要修改Javac的Grammer。 Java SE7的语法:http:/

javac not recognized

早过忘川 提交于 2019-11-30 19:32:22
What can I do when I keep receiving the error 'javac' is not recognized as an internal or external command, operable program or batch file when I want to compile my jar or .class file? Thanks Make sure %JAVA_HOME%/bin is on your %PATH% (or $JAVA_HOME on the $PATH in *nix). It means that it is not in your path. You have the following options: 1) Change to the directory where javac lives before calling it. 2) Use the full path to javac when making the call, e.g. C:\java\jdk1.6.0_12\bin\javac ... 3) Add the javac directory to the PATH environment variable This just means that javac isn't in your

What is the “Use '--release' option” in IntelliJ 2018.1 preferences?

独自空忆成欢 提交于 2019-11-30 19:26:03
In the preferences for IntelliJ 2018.1 (Build, Execution, Deployment > Compiler > Java Compiler) is an checkbox labeled: Use '--release' option for cross-compilation (Java 9 and later) I found for information when doing an internet search. The "?" help icon give a 404 error when clicked. What is the purpose/function of this option? CrazyCoder The help section can be found here : By default, this option is selected. IntelliJ IDEA deduces from project settings when the cross-compilation is needed and automatically applies the --release compiler option for Java 9. What is the --release option? It