Questions tagged [java-7]

Java SE version 7 was released in 2011. The new features, in comparison to the version 6, include dynamic language support, compressed pointers, small language extensions, elliptic curve cryptography, new network protocols, the ability to use Strings as case values in a switch statement, and various system library extensions.

Oracle has two products that implement Java Platform Standard Edition (Java SE) 7: Java SE Development Kit (JDK) 7 and Java SE Runtime Environment (JRE) 7.

JDK 7 is a superset of JRE 7, and contains everything that is in JRE 7, plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE 7 provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language.

The following conceptual diagram illustrates Java component technologies:

Java component technologies stack

See for more information.

Java 7 Official Documentation: http://docs.oracle.com/javase/7/docs/api/

Java SE 7 Features and Enhancements

2955 questions
694
votes
33 answers

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] COMPILATION ERROR : [INFO]…
Sai prateek
  • 10,642
  • 8
  • 39
  • 60
468
votes
7 answers

What is the point of the diamond operator (<>) in Java 7?

The diamond operator in java 7 allows code like the following: List list = new LinkedList<>(); However in Java 5/6, I can simply write: List list = new LinkedList(); My understanding of type erasure is that these are exactly the…
tofarr
  • 7,128
  • 3
  • 20
  • 27
393
votes
27 answers

Installed Java 7 on Mac OS X but Terminal is still using version 6

I've installed JDK 7u7 downloaded from oracle's website. But after installation, the terminal is still showing java version 6 $java -version java version "1.6.0_35" Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811) Java HotSpot(TM)…
Yang
  • 9,336
  • 15
  • 41
  • 52
307
votes
4 answers

Create a Path from String in Java7

How can I create a java.nio.file.Path object from a String object in Java 7? I.e. String textPath = "c:/dir1/dir2/dir3"; Path path = ?; where ? is the missing code that uses textPath.
mat_boy
  • 10,930
  • 19
  • 62
  • 103
298
votes
27 answers

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
Quintin Par
  • 14,646
  • 27
  • 87
  • 142
298
votes
9 answers

Is "Java Concurrency In Practice" still valid?

Is Java Concurrency in Practice still valid? I am wondering whether the ideas, concepts and implementation described in the book are still compliant with the latest Java versions. I ask because the latest edition was done in 2006.
M-D
  • 9,777
  • 9
  • 27
  • 35
198
votes
20 answers

How to set specific Java version to Maven?

On my machine I have two Java versions installed: (1.6 and 1.7 installed manually by me). I need both of them for different projects. But for Maven I need 1.7, but my Maven uses the 1.6 Java version. How can I set Maven to use 1.7?
andPat
  • 3,073
  • 6
  • 22
  • 33
188
votes
8 answers

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 understand the bytecode of Java 7?
Daniel Ryan
  • 6,566
  • 4
  • 40
  • 60
188
votes
2 answers

Java SafeVarargs annotation, does a standard or best practice exist?

I've recently come across the java @SafeVarargs annotation. Googling for what makes a variadic function in Java unsafe left me rather confused (heap poisoning? erased types?), so I'd like to know a few things: What makes a variadic Java function…
Oren
  • 3,952
  • 3
  • 28
  • 37
178
votes
8 answers

How to set -source 1.7 in Android Studio and Gradle

I'm getting following error when trying to compile my project in Android Studio: Gradle: error: diamond operator is not supported in -source 1.6 I have 1.7 set as target in all project preferences I've found. Also the path displayed in project…
simekadam
  • 7,034
  • 10
  • 49
  • 75
166
votes
5 answers

Can Java 8 code be compiled to run on Java 7 JVM?

Java 8 introduces important new language features such as lambda expressions. Are these changes in the language accompanied by such significant changes in the compiled bytecode that would prevent it from being run on a Java 7 virtual machine without…
Nicola Ambrosetti
  • 2,459
  • 3
  • 20
  • 31
164
votes
8 answers

java.nio.file.Path for a classpath resource

Is there an API to get a classpath resource (e.g. what I'd get from Class.getResource(String)) as a java.nio.file.Path? Ideally, I'd like to use the fancy new Path APIs with classpath resources.
Louis Wasserman
  • 172,699
  • 23
  • 307
  • 375
152
votes
5 answers

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

I have a method for getting users from a database with JDBC: public List getUser(int userId) { String sql = "SELECT id, name FROM users WHERE id = ?"; List users = new ArrayList(); try { Connection con =…
Jonas
  • 97,987
  • 90
  • 271
  • 355
139
votes
2 answers

How to set IntelliJ IDEA Project SDK

I just installed IntelliJ IDEA and when I try to create my first Project it asks for me to set up the Project SDK. When I click on "JDK" it asks for me to select the home directory of the JDK as shown in this image. I'm having trouble locating…
user2419553
  • 1,529
  • 2
  • 10
  • 7
130
votes
2 answers

Java: int array initializes with nonzero elements

According to the JLS, an int array should be filled by zeros just after initialization. However, I am faced with a situation where it is not. Such a behavior occurs first in JDK 7u4 and also occurs in all later updates (I use 64-bit implementation).…
Stanislav Poslavsky
  • 2,288
  • 1
  • 20
  • 36
1
2 3
99 100