javac

How to compile to target Java 1.0

僤鯓⒐⒋嵵緔 提交于 2019-12-21 02:33:52
问题 I want to compile my code down to Java version 1.0. I managed to compile down to 1.1 : $ java -version openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) $ javac -target 1.2 -source 1.2 MyClass.java (works with some warnings) $ javac -target 1.1 -source 1.2 MyClass.java (works with some warnings) But the target option does not seem to accept 1.0 : $ javac -target 1.0 -source 1.2 MyClass.java

Java compilation errors limited to 100

房东的猫 提交于 2019-12-20 09:43:07
问题 I have a Java file,which when I compiled, I will be able to see only first 100 errors on console after that java compiler(javac) exits. How will I be able to see all the compilation errors on console? Thanks in advance- opensid 回答1: Generally the compiler will give up after 100 errors. Most of the errors after this point will likely be caused by one of the first errors. If you must have more errors check out the javac options -Xmaxerrs and -Xmaxwarns 回答2: If you're using gradle: allprojects {

Setup Java 6 annotation processing configuration for eclipse compiler with maven

谁说我不能喝 提交于 2019-12-20 08:45:30
问题 What's the best way to setup the eclipse project compiler configuration for Java 6 annotation processors? My solution is to setup the org.eclipse.jdt.apt.core.prefs and factorypath files manually. This is a bit cumbersome: Reference the processor jar in the factorypath file Configure the eclipse annotation processor output directory (org.eclipse.jdt.apt.genSrcDir property in org.eclipse.jdt.apt.core.prefs ) Add the eclipse annotation processor output directory as source folder One problem is

new to programming in Java - issues with Javac [closed]

风格不统一 提交于 2019-12-20 06:14:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am new to programming in Java and am trying to compile a Java source file but I keep getting the following message when I type javac Welcome.java Welcome.java:5: error: cannot find symbol System.out.println("Welcome to Java!"); ^ symbol: method printIn<String> location: variable out of type PrintStream 1 error

Compiler is creating extra class files with $ in them

冷暖自知 提交于 2019-12-20 05:21:14
问题 I'm using Eclipse and I've written a Java application using SWT. When Eclipse compiles my program, it renames my main file into 4 different files like this: MainFile.class MainFile$1.class MainFile$2.class MainFile$3.class When I go to run this program from command line, I get Could not find the main class: MainFile.class. Program will exit. I really don't understand why this is happening. 回答1: The $ classes are for anonymous inner classes and perfectly normal. Could we see the command line

Setting javac options for SBT dependencies

微笑、不失礼 提交于 2019-12-20 01:13:57
问题 I am having problems compiling a Java dependency loaded via GIT: object ApplicationBuild extends Build { lazy val project = Project("root", file(".")).dependsOn(RootProject(riakJavaClient)) lazy val riakJavaClient = uri("git://github.com/basho/riak-java-client") } The error I am receiving from sbt compile is: [info] Compiling 134 Java sources to /Users/lawrencewagerfield/.sbt/0.13/staging/da0e66c4764a467c8977/riak-java-client/target/scala-2.10/classes... [error] /Users/lawrencewagerfield/.sbt

Why javac does not optimize even simple code?

谁说我不能喝 提交于 2019-12-19 16:51:23
问题 Given the following code: public class MainClass { public static int f(){ int i=0; i++; return i; } } the compiler javac produces the following code: Compiled from "MainClass.java" public class latte_jvm.MainClass { public static int f(); Code: 0: iconst_0 1: istore_0 2: iinc 0, 1 5: iload_0 6: ireturn } Function f does really simple thing - it just returns 1. It's so directly translated that it makes me hard to believe that java compiler does any optimizations at all. Why java compiler

Why javac does not optimize even simple code?

核能气质少年 提交于 2019-12-19 16:50:10
问题 Given the following code: public class MainClass { public static int f(){ int i=0; i++; return i; } } the compiler javac produces the following code: Compiled from "MainClass.java" public class latte_jvm.MainClass { public static int f(); Code: 0: iconst_0 1: istore_0 2: iinc 0, 1 5: iload_0 6: ireturn } Function f does really simple thing - it just returns 1. It's so directly translated that it makes me hard to believe that java compiler does any optimizations at all. Why java compiler

Java compiler prohibit the creation in the inner class method with same name as in the outer class if the signatures are different

醉酒当歌 提交于 2019-12-19 12:45:13
问题 Why this code work: class Parent { private void methodA(String a){ System.out.println(a); } class Inner { void test(int a){ methodA("1"); } } } But This code not work(I just add method to inner class with same name and another signature): class Parent { private void methodA(String a){ System.out.println(a); } class Inner { private void methodA(int a){ System.out.println(a); } void test(int a){ methodA("1"); } } } I do not ask how to make it work. I want to mean why the second option doesn't

Compile a JDK 8 project + a JDK 9 “module-info.java” in Gradle

此生再无相见时 提交于 2019-12-19 10:18:54
问题 I'm working on a Java library targeting JDK 8, and I'm building it in Gradle 5 using OpenJDK 11. In order to target JDK 8, I'm javac's --release option. However, I'd also like my library to be JPMS-compatible. In other words: I'd like to provide a module-info.class compiled with --release 9 (option 3 in Stephen Colebourne's scale), while all the rest is compiled with --release 8 . MCVE build.gradle : plugins { id 'java' id 'org.javamodularity.moduleplugin' version '1.4.1' // * } repositories