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

2995 questions
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,398
  • 2
  • 24
  • 36
129
votes
2 answers

Why does the difference between 30 March and 1 March 2020 erroneously give 28 days instead of 29?

TimeUnit.DAYS.convert( Math.abs( new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").parse("30-03-2020 00:00:00").getTime() - new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").parse("1-03-2020 00:00:00").getTime() ), …
Joe
  • 7,749
  • 19
  • 60
  • 110
121
votes
5 answers

invalid target release: 1.7

I have seen similar questions, but haven't yet found the answer. Using maven compile, I get: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project api: Fatal error compiling: invalid…
Karan
  • 14,824
  • 24
  • 91
  • 157
121
votes
2 answers

Technically what is the main difference between Oracle JDK and OpenJDK?

I have been using OpenJDK for ages, initially for small projects where it has no problems. But since I started to play with it for big toys, I started to notice random/unknown fatal error and crashes (with H.264 codecs, etc.), and it was a nightmare…
user285594
121
votes
13 answers

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 what I get: java.lang.IllegalArgumentException:…
Lakatos Gyula
  • 3,949
  • 7
  • 35
  • 56
118
votes
9 answers

After Installing Java JDK 7 For Mac OS X - mvn -version still shows java version 1.6.0_31

Oracle released Java JDK 7 on April 26 for Mac OS X. I followed the install instructions and when I do java -version in a terminal window I get: java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b21) Java HotSpot(TM) 64-Bit…
Bruce Phillips
  • 2,740
  • 3
  • 18
  • 17
109
votes
16 answers

How do I use JDK 7 on Mac OSX?

I would like to use the WatchService API as mentioned in this link: http://download.oracle.com/javase/tutorial/essential/io/notification.html After reading around, I found out that WatchService is part of the NIO class which is scheduled for JDK 7.…
oky_sabeni
  • 7,672
  • 15
  • 65
  • 89
107
votes
2 answers

Differences in auto-unboxing between Java 6 vs Java 7

I have noted a difference in auto unboxing behavior between Java SE 6 and Java SE 7. I'm wondering why that is, because I can't find any documentation of changes in this behavior between these two versions. Here's a simple example: Object[] objs =…
Morty
  • 1,706
  • 1
  • 12
  • 25
99
votes
4 answers

How to check the extension of a Java 7 Path

I'd like to check if a Path (introduced in Java 7) ends with a certain extension. I tried the endsWith() method like so: Path path = Paths.get("foo/bar.java") if (path.endsWith(".java")){ //Do stuff } However, this doesn't seem to work because…
Thunderforge
  • 19,637
  • 18
  • 83
  • 130
96
votes
8 answers

New features in java 7

What new features in java 7 is going to be implemented? And what are they doing now?
Serik
92
votes
16 answers

Java G1 garbage collection in production

Since Java 7 is going to use the new G1 garbage collection by default is Java going to be able to handle an order of magnitude larger heap without supposed "devastating" GC pause times? Has anybody actually implemented G1 in production, what were…
benstpierre
  • 32,833
  • 51
  • 177
  • 288
91
votes
2 answers

Am I using the Java 7 try-with-resources correctly

I am expecting the buffered reader and file reader to close and the resources released if the exception is throw. public static Object[] fromFile(String filePath) throws FileNotFoundException, IOException { try (BufferedReader br = new…
Cheetah
  • 13,785
  • 31
  • 106
  • 190
91
votes
10 answers

java.lang.VerifyError: Expecting a stackmap frame at branch target JDK 1.7

After upgrading to JDK 1.7 I am getting below exception: java.lang.VerifyError: Expecting a stackmap frame at branch target 71 in method…
Sanguine
  • 973
  • 1
  • 8
  • 10
90
votes
5 answers

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 "main" java.lang.UnsupportedClassVersionError: a (Unsupported…
Adnan
  • 4,517
  • 15
  • 44
  • 54
83
votes
5 answers

Maximum size of a method in Java 7 and 8

I know that a method cannot be larger than 64 KB with Java. The limitation causes us problems with generated code from a JavaCC grammar. We had problems with Java 6 and were able to fix this by changing the grammar. Has the limit been changed for…
LaurentG
  • 11,128
  • 9
  • 51
  • 66