javac

Javac is not found

ⅰ亾dé卋堺 提交于 2019-11-30 03:39:27
I'm running Windows 8 and I can not get javac to work. I have set my PATH in environmental variables to C:\Program Files (x86)\Java\jdk1.7.0_17\bin I have tried both with and without ';' but to no avail. I recently had this issue on my desktop and adding ; worked but it's not in this case. I have made sure that javac does exist in the bin too. Any suggestions on fixes would be greatly appreciated. EDITS echo %PATH% gives: C:\Users\Arktri\Desktop>echo %PATH% C:\Program Files (x86)\Intel\iCLS Client\; C:\Program Files\Intel\iCLS Client\; C:\Windows\system32;C:\Windows; C:\Windows\System32\Wbem;

compiling only part of the source tree with ant

柔情痞子 提交于 2019-11-30 03:19:01
问题 Say I have my sources in my src/ tree (and possibly in my test/ tree). Say I would like to compile only part of that tree. The reasons why I might want to do that are various. Just as an example, I might want to create the smallest possible jar (without including certain classes), or I might want the fastest compile time for what I am compiling. I absolutely want to compile all the dependencies, though! This can be easily achieved from the command line with: javac -d build/ -cp whatever

Annotation Processor, generating a compiler error

 ̄綄美尐妖づ 提交于 2019-11-30 03:18:39
I'm trying to create a custom annotation that, for example, ensures that a field or method is both public and final , and would generate a compile time error if the field or method is not both public and final , as in these examples: // Compiles @PublicFinal public final int var = 2; // Compiles @PublicFinal public final void myMethod {} // Compile time error @PublicFinal private final int fail = 2; So far, I've made both the custom annotation interface: import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang

Equality comparison of `boolean` and `Object` allowed?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 02:40:30
问题 The following code public class TestComparison { public static void main(String[] args) throws Exception { boolean b = true; Object o = new Boolean(true); System.out.println("comparison result: "+ (o == b)); // Eclipse complains about this expression } } compiles without errors with javac V1.7.0_15, and prints "false" when run. However, Eclipse Juno complains about "Incompatible operand types Object and boolean". Apparently javac autoboxes the primitive boolean b , and then compares o and

javac error: inconvertible types with generics?

点点圈 提交于 2019-11-29 22:21:50
There are several other SO questions talking about generics compiling OK w/ Eclipse's compiler but not javac (i.e. Java: Generics handled differenlty in Eclipse and javac and Generics compiles and runs in Eclipse, but doesn't compile in javac ) -- however this looks like a slightly different one. I have an enum class: public class LogEvent { public enum Type { // ... values here ... } ... } and I have another class with a method that takes in arbitrary objects of types descended from Enum : @Override public <E extends Enum<E>> void postEvent( Context context, E code, Object additionalData) {

Error: Failed to run “javac -version”, make sure that you have a JDK Installed

夙愿已清 提交于 2019-11-29 21:46:32
问题 Error: Failed to run "javac -version", make sure that you have a JDK installed. You can get it from: http://www.oracle.com/technetwork/java/javase/downloads. Your JAVA_HOME is invalid: C:\Program Files\Java\jdk1.8.0_152; [ERROR] An error occurred while running cordova run android (exit code 1) My JAVA_HOME : C:\Program Files\Java\jdk1.8.0_152;C:\Program Files\Java\jdk1.8.0_152\bin; ANDROID_HOME: C:\Users\Felipe\AppData\Local\Android\sdk; Path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%

Setting JAVA_HOME when running Ant from Java

你说的曾经没有我的故事 提交于 2019-11-29 21:16:42
问题 The reason is long and boring, but I need to run an Ant script to compile Java 1.5 code from a Java 1.4 app. I keep getting this error, though: BUILD FAILED build.xml:16: 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. It is currently set to "C:\j2sdk1.4.2_16\jre" In my code, I have: Project p = new Project(); p.setUserProperty("ant.file", buildFile.getAbsolutePath()); p.setProperty("java.home", "C:\Program Files

Difference in behaviour of the ternary operator on JDK8 and JDK10

僤鯓⒐⒋嵵緔 提交于 2019-11-29 20:33:39
Consider the following code public class JDK10Test { public static void main(String[] args) { Double d = false ? 1.0 : new HashMap<String, Double>().get("1"); System.out.println(d); } } When running on JDK8, this code prints null whereas on JDK10 this code results in NullPointerException Exception in thread "main" java.lang.NullPointerException at JDK10Test.main(JDK10Test.java:5) The bytecode produced by the compilers is almost identical apart from two additional instructions produced by the JDK10 compiler which are related to autoboxing and seem to be responsible for the NPE. 15:

In Java 8, why were Arrays not given the forEach method of Iterable?

南楼画角 提交于 2019-11-29 20:16:31
I must be missing something here. In Java 5, the "for-each loop" statement (also called the enhanced for loop) was introduced. It appears that it was introduced mainly to iterate through Collections . Any collection (or container) class that implements the Iterable interface is eligible for iteration using the "for-each loop". Perhaps for historic reasons, the Java arrays did not implement the Iterable interface. But since arrays were/are ubiquitous, javac would accept the use of for-each loop on arrays (generating bytecode equivalent to a traditional for loop). In Java 8, the forEach method

How can i make gitbash find the javac command?

自古美人都是妖i 提交于 2019-11-29 19:51:31
问题 I made my gitrepository and committed it. Inserted one java-file and wanted to to compile it ,but it gave me this: Bernard@BERNARD-PC /c/users/bernard/desktop/git2 (master) $ javac TestGUI.java sh.exe": javac: command not found It used to work in school on their computer,but at home on my laptop I cant make it work. EDIT : I added javac as environment variable: EDIT : Short term solution for the duration of the runtime of gitbash enter: `export PATH=$PATH:"/C/Program Files/Java/jdk1.7.0_21