All Questions

386
votes
7answers
121097 views

What is the point of the diamond operator in Java 7?

The diamond operator in java 7 allows code like the following: List<String> list = new LinkedList<>(); However in Java 5/6, I can simply write: List<String> list = new LinkedList...
13
votes
1answers
7402 views

javafx 8 compatibility issues - FXML static fields

I have designed a javafx application which works fine in jdk 7. When I try to run it in java 8 I am getting the below exceptions: javafx.fxml.LoadException: at javafx.fxml.FXMLLoader.constructLoadEx...
166
votes
19answers
208069 views

Recursively list files in Java

How do I recursively list all files under a directory in Java? Does the framework provide any utility? I saw a lot of hacky implementations. But none from the framework or nio
10
votes
5answers
15608 views

Error when using LogManager (l4j2) with Java 8 (java.lang.reflect.AnnotatedElement cannot be resolved)

I just encountered a strange error when switching the JDK version of a new Project of mine from 7u45 to 8u20. A harmless LogManager declaration at the beginning of my class is being refused with the f...
46
votes
6answers
89054 views

Java error: Comparison method violates its general contract

I saw many questions about this, and tried to solve the problem, but after one hour of googling and a lots of trial & error, I still can't fix it. I hope some of you catch the problem. This is wh...
92
votes
4answers
60550 views

How should I use try-with-resources with JDBC?

I have a method for getting users from a database with JDBC: public List<User> getUser(int userId) { String sql = "SELECT id, name FROM users WHERE id = ?"; List<User> users = new...
182
votes
8answers
48119 views

Java 7 language features with Android

Just wondering if anyone has tried using new Java 7 language features with Android? I know that Android reads the bytecode that Java spits out and turns it to dex. So I guess my question is can it und...
77
votes
8answers
88813 views

Java 7 (JDK 7) garbage collection and documentation on G1

Java 7 has been out for a while now, but I cannot find any good resources on the configuration of the garbage collectors, specifically the new G1 collector. My questions: Is G1 the default collecto...
78
votes
5answers
233089 views

Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)

Possible Duplicate: unsupported major .minor version 51.0 I installed JDK7, a simple hello word program gets compile but when I run this I got following exception. Exception in thread "mai...
378
votes
23answers
510583 views

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

I'm compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this: Windows-->preferences-->installed jres--> jdk1.7.xx path But this is showing an error [ERROR]...

Previous Next