javac

Drawbacks of javac -parameters flag

≡放荡痞女 提交于 2019-12-10 16:16:37
问题 I want to try some frameworks features that required names of parameter in runtime, so I need to compile my app with -parameters and it will store the names of parameter in JVM byte code. Which drawbacks except the size of jar/war exist of this parameter usage? 回答1: The addition of parameter names to the class file format is covered by JEP 118, which was delivered in Java 8. There was a little bit of discussion about why inclusion of parameter names was made optional in OpenJDK email threads

javac 8 error while metamodel generation (hibernate-jpamodelgen)

泪湿孤枕 提交于 2019-12-10 16:06:08
问题 I am trying to auto generate metamodel classes using hibernate-jpamodelgen library in Play Framework. My build.sbt file is like this: libraryDependencies ++= Seq( javaCore, // filters, cache, "org.springframework" % "spring-context" % "4.0.4.RELEASE", "org.springframework" % "spring-orm" % "4.0.4.RELEASE", "org.springframework" % "spring-jdbc" % "4.0.4.RELEASE", "org.springframework" % "spring-tx" % "4.0.4.RELEASE", "org.springframework" % "spring-expression" % "4.0.4.RELEASE", "org

What is the effect of the dot (.) in the Java classpath?

你。 提交于 2019-12-10 15:55:42
问题 This is an example question from "SCJP mock exam": Given the default classpath: /foo And this directory structure: foo | test | xcom |--A.class |--B.java And these two files: package xcom; public class A { } package xcom; public class B extends A { } Which allows B.java to compile? (Choose all that apply.) A. Set the current directory to xcom then invoke javac B.java B. Set the current directory to xcom then invoke javac -classpath . B.java C. Set the current directory to test then invoke

How to compile this code with Java 10, Ant and the Eclipse compiler?

自作多情 提交于 2019-12-10 15:28:36
问题 I am trying to compile this simple code using Java 10, Ant and the Eclipse compiler: import java.util.ArrayList; import javax.xml.bind.JAXBException; class Test { void foo() throws JAXBException { throw new JAXBException("hi there"); } void bar() { new ArrayList<String>(); } } This is the Ant file I am using: <project name="Java 10 test"> <target name="compile-javac" depends="clean, print-version-info"> <javac release="10" includeantruntime="false"> <src path="."/> <compilerarg value="--add

Use javac with multiple specific jars on classpath in Linux (tilde doesn't expand after colon)

泪湿孤枕 提交于 2019-12-10 14:58:44
问题 I'm trying to compile a java source file that uses two jar files (trove and apache commons collections) via commands similar to the following javac -cp ~/.m2/repository/gnu/trove/trove/3.0.0/trove-3.0.0.jar:~/git-workspace/grid/libs/commons-collections-3.2.1.jar $(find . -name TimeJavaCode.java) In the above case, the commons code is not successfully included and there is a compile error where I'm using the commons library. If I reverse the order of the imports, then there are compile errors

Which tool for colorizing output of javac?

断了今生、忘了曾经 提交于 2019-12-10 14:40:04
问题 We have a hugely parallelized build process, so I frequently have to browse through large amounts of output from javac to find a build error. To make this easier it would be nice if there were some tool that will colorize the output of javac to my terminal, highlighting errors in the code. What tool can I use to colorize the output of javac? 回答1: I ended up using a tool called Generic Colorizer Tool and write my own configuration for colorizing the most important output. Works just fine. :)

How to use jar files without package information?

旧巷老猫 提交于 2019-12-10 14:16:53
问题 I have a jar called "MyTools". The jar is in c:\data folder. I created a new file in the same folder called "UseTools.java". Now I would like to use some of the classes from the MyTools.jar in my UseTools.java. I tried this but it doesnt seem to work: import MyTools.*; public class UseTools { public static void main(String[] args) { MyTools.SomeClass foo = new SomeClass(); SomeClass.doSomething(); } } I tried to compile this with: javac -cp . UseTools.java and got this error message: UseTools

How to run javac with paths as argument that contain white spaces?

放肆的年华 提交于 2019-12-10 14:03:38
问题 I am trying to run the following javac -Xlint:unchecked -classpath C:/Users/a b/workspace/ @C:/Users/a b/workspace/files_to_compile but I'm getting a javac: invalid flag C:/users/a I've also tried to surround both paths with double quotes but it doesn't seem to help a bit: javac -Xlint:unchecked -classpath "C:/Users/a b/workspace/" @"C:/Users/a b/workspace/files_to_compile" What am I doing wrong? This same code worked correctly in other computers (probably because they didn't have any white

JDK8 with -source 1.7 [Default Methods]

拟墨画扇 提交于 2019-12-10 12:44:41
问题 I have the following class. public class ZonedDateTimeToInstant { public static void main(final String[] args) throws NoSuchMethodException { assert ChronoZonedDateTime.class.isAssignableFrom(ZonedDateTime.class); final Method toInstant = ChronoZonedDateTime.class.getMethod("toInstant"); final ZonedDateTime now = ZonedDateTime.now(); final Instant instant = now.toInstant(); System.out.println(instant); } } It just compiles fine. & javac ZonedDateTimeToInstant.java And it fails with -source 1

java comand works but not javac?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:53:59
问题 ok so I got a new PC Windows 7 Pro 64 bit Service Pack 1 I installed jdk-7u25-windows-x64 ( jdk 1.7.0_25) It is installed in default location C:\Program Files\Java\jdk1.7.0_25 I set the JAVA_HOME environment variable to C:\Program Files\Java\jdk1.7.0_25 I added %JAVA_HOME%\bin to the Path environment variable (yes I used a ; before I added it) Clicked Ok Closed all CMD windows opened them up And now If I run the command java I get the expected output But If I run the javac command I get this