javac

Compiling four java files within one package using javac

青春壹個敷衍的年華 提交于 2020-01-09 12:23:24
问题 I have four java files in my folder. They are all in the same package. Here's the package declaration package com.osama.GHide All of these classes are in the same package. I want to know how can I compile them using javac (i mean i do not know how to compile multiple files that are using each other). And once that is done how do I launch then using java command in the CLI? here are the file names. EnteringPoint.java HidingProcess.java ListFiles.java 回答1: From the project's root directory:

Compiling four java files within one package using javac

风格不统一 提交于 2020-01-09 12:23:24
问题 I have four java files in my folder. They are all in the same package. Here's the package declaration package com.osama.GHide All of these classes are in the same package. I want to know how can I compile them using javac (i mean i do not know how to compile multiple files that are using each other). And once that is done how do I launch then using java command in the CLI? here are the file names. EnteringPoint.java HidingProcess.java ListFiles.java 回答1: From the project's root directory:

Is this valid Java?

六月ゝ 毕业季﹏ 提交于 2020-01-09 04:13:19
问题 Is this valid Java? import java.util.Arrays; import java.util.List; class TestWillThatCompile { public static String f(List<String> list) { System.out.println("strings"); return null; } public static Integer f(List<Integer> list) { System.out.println("numbers"); return null; } public static void main(String[] args) { f(Arrays.asList("asdf")); f(Arrays.asList(123)); } } Eclipse 3.5 says yes Eclipse 3.6 says no Intellij 9 says yes Sun javac 1.6.0_20 says yes GCJ 4.4.3 says yes GWT compiler says

Spring 2.0 Annotations and ant

六月ゝ 毕业季﹏ 提交于 2020-01-07 04:28:11
问题 I have an old appfuse project, running Spring 2.0, and Java 1.6, and I'm trying to get Transaction annotation support (and other annotations) running. But, when I add this to our class: @Transactional public class ... { } We get an ant compile issue, like: [javac] symbol: class Transactional [javac] @Transactional [javac] ^ How do I tell ant which Spring transactions it should be using? 回答1: This looks like a simple import problem to me. Have you imported the class org.springframework

How can I build my jar file so that users who use the library will be able to see the javadoc in Eclipse

冷暖自知 提交于 2020-01-06 03:26:32
问题 I'm working on a small library for our in-company use, and have been heavily documenting it. Now I'm building my jar with the following code: <project name="commonutils" default="compile" basedir="."> <property name="src" location="src" /> <property name="build" location="buildDirecotry" /> <target name="compile"> <delete file="${ant.project.name}.jar" /> <mkdir dir="${build}"/> <javac srcdir="${src}" destdir="${build}" debug="on" target="1.5"> <classpath> <pathelement location="lib/build

Can't resolve -source errors on IntelliJ with regards to Project Language Level

ε祈祈猫儿з 提交于 2020-01-05 09:37:09
问题 I am running into errors like these while trying to build my project on IntelliJ on Mac. Error:(12, 39) java: diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) Error:(122, 48) java: method references are not supported in -source 1.5 (use -source 8 or higher to enable method references) Error:(124, 51) java: lambda expressions are not supported in -source 1.5 (use -source 8 or higher to enable lambda expressions) Looking at other answers on

Why can't I call a method outside of an anonymous class of the same name

喜你入骨 提交于 2020-01-04 05:38:09
问题 The code at the end produces a compile error: NotApplicable.java:7: run() in cannot be applied to (int) run(42); ^ 1 error The question is why? Why does javac think I am calling run(), and does not find run(int bar)? It correctly called foo(int bar). Why do I have to use NotApplicable.this.run(42);? Is it a bug? public class NotApplicable { public NotApplicable() { new Runnable() { public void run() { foo(42); run(42); // uncomment below to fix //NotApplicable.this.run(42); } }; } private

Javac version 1.7 not able to build for target 1.7

≡放荡痞女 提交于 2020-01-04 02:04:55
问题 I am trying to compile Java code, with Sun Java JDK 1.7.0_17, on a Linux Mint system, but I'm getting this problem. $ javac -version -target 1.7 javac 1.7.0_17 javac: invalid target release: 1.7 -target 1.6 doesn't work either. Target 1.5 works, but I get a version problem as such, $ javac -version -target 1.5 HelloWorld.java javac 1.7.0_17 HelloWorld.java:2: cannot access java.lang.Object bad class file: /usr/lib/jvm/jdk1.7.0_17/jre/lib/rt.jar(java/lang/Object.class) class file has wrong

Javac version 1.7 not able to build for target 1.7

旧城冷巷雨未停 提交于 2020-01-04 02:04:13
问题 I am trying to compile Java code, with Sun Java JDK 1.7.0_17, on a Linux Mint system, but I'm getting this problem. $ javac -version -target 1.7 javac 1.7.0_17 javac: invalid target release: 1.7 -target 1.6 doesn't work either. Target 1.5 works, but I get a version problem as such, $ javac -version -target 1.5 HelloWorld.java javac 1.7.0_17 HelloWorld.java:2: cannot access java.lang.Object bad class file: /usr/lib/jvm/jdk1.7.0_17/jre/lib/rt.jar(java/lang/Object.class) class file has wrong

How to exclude a source package using javac in Ant?

女生的网名这么多〃 提交于 2020-01-03 09:25:30
问题 I've looked at a bunch of different examples, and tried several variations, but can't seem to get this working correctly. It also appears that you can't exclude an entire directory with javac, but only files, which I suppose means you can't specify a package? Here is what I have: <javac srcdir="src" destdir="WEB-INF/classes" excludes="path/to/excluded/package/*.java"> <classpath refid="compile.classpath"/> <!-- reference defined earlier --> </javac> 回答1: You can exclude whole directories or