Questions tagged [java-6]

Java SE version 6 was released in December 2006. Use this tag for questions specific to this version of Java.

Java SE 6 was an evolutionary change over the previous version. It did not include extensive language or JVM changes, however such changes were planned for Java SE 7 which was supposed to be released much sooner. (See here for what changed in Java 6).

As a stop-gap to the much delayed Java 7, Sun (since purchased by Oracle) introduced Java SE 6 Update 10, which despite its modest version numbering, represented extensive improvements to the GUI capabilities of Java in order to support JavaFX and Sun's renewed attempt to make Java successful in the GUI arena.

Internally, Java is numbered with a "1." before the number, so it will report itself as "1.6.0_" with an update number at the end. Starting with version 6, Sun dropped the ".0" from its marketed version number, so instead of 5.0 as previously done, it was Java 6.

Only use this tag if your question is specifically related to features of this version. Just because you are using this version, doesn't mean you need this tag. Use in addition to or instead of this tag.

See for more information.

1391 questions
1242
votes
34 answers

Dealing with "java.lang.OutOfMemoryError: PermGen space" error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a…
Chris
  • 632
  • 4
  • 11
  • 18
298
votes
29 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
  • 4,153
  • 7
  • 24
  • 36
256
votes
4 answers

Get java.nio.file.Path object from java.io.File

Is it possible to get a Path object from a java.io.File? I know you can convert a path to a file using toFile() method, but I couldn't find the opposite conversion. Is there a way to do this in Java 6 or lower?
Karlovsky120
  • 6,212
  • 8
  • 41
  • 94
221
votes
15 answers

Get keys from HashMap in Java

I have a Hashmap in Java like this: private Map team1 = new HashMap(); Then I fill it like this: team1.put("United", 5); How can I get the keys? Something like: team1.getKey() to return "United".
masb
  • 2,813
  • 3
  • 20
  • 20
212
votes
6 answers

Most concise way to convert a Set to a List

For example, I am currently doing this: Set setOfTopicAuthors = .... List list = Arrays.asList( setOfTopicAuthors.toArray( new String[0] ) ); Can you beat this ?
Jacques René Mesrine
  • 46,127
  • 27
  • 66
  • 104
141
votes
7 answers

java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0

I am trying to build an application, but it gives some error. My JDK version is given below: java version "1.6.0_30" Java(TM) SE Runtime Environment (build 1.6.0_30-b12) Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing) Here is my…
vivek rai
  • 2,109
  • 10
  • 25
  • 21
132
votes
10 answers

Is it possible to read the value of a annotation in java?

this is my code: @Column(columnName="firstname") private String firstName; @Column(columnName="lastname") private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { …
BeeS
  • 1,329
  • 2
  • 9
  • 3
111
votes
2 answers

Ternary operator in Java only evaluating one expression since Java 7 - was that different in Java 1.6 and lower?

Preparing for the Oracle Certified Associate Java SE 8 Programmer 1 exam, I came across the following paragraph about the ternary expression in the official Study Guide: Ternary Expression Evaluation As of Java 7, only one of the right-hand…
Mathias Bader
  • 3,585
  • 7
  • 39
  • 61
94
votes
6 answers

Using File.listFiles with FileNameExtensionFilter

I would like to get a list of files with a specific extension in a directory. In the API (Java 6), I see a method File.listFiles(FileFilter) which would do this. Since I need a specific extension, I created a FileNameExtensionFilter. However I get a…
Anu
  • 1,337
  • 1
  • 10
  • 21
77
votes
4 answers

Which JDK version (Language Level) is required for Android Studio?

I am a new comer to the android world and with a .NET background. I am trying to install the Android Studio but I am having a mismatch on Android.com about the JDK version required for developing Android applications. From the SDK web page it states…
Moslem Ben Dhaou
  • 6,897
  • 8
  • 62
  • 93
60
votes
9 answers

How to define a relative path in java

Here is the structure of my project : I need to read config.properties inside MyClass.java. I tried to do so with a relative path as follows : // Code called from MyClass.java File f1 = new File("..\\..\\..\\config.properties"); String path =…
ishk
  • 1,873
  • 5
  • 19
  • 22
56
votes
5 answers

Simple Java HTTPS server

I need to set up a really lightweight HTTPS server for a Java application. It's a simulator that's being used in our development labs to simulate the HTTPS connections accepted by a piece of equipment in the wild. Because it's purely a lightweight…
Andrew
  • 11,894
  • 12
  • 69
  • 85
55
votes
9 answers

intern() behaving differently in Java 6 and Java 7

class Test { public static void main(String...args) { String s1 = "Good"; s1 = s1 + "morning"; System.out.println(s1.intern()); String s2 = "Goodmorning"; if (s1 == s2) { …
Mohammad Faisal
  • 5,783
  • 15
  • 70
  • 117
50
votes
9 answers

How to use TLS 1.2 in Java 6

It seems that Java 6 supports TLS up to v1.0, is there any way to use TLS 1.2 in Java 6? Maybe a patch or a particular update of Java 6 will have support for it?
alex
  • 497
  • 1
  • 4
  • 4
49
votes
10 answers

The JDK is missing and is required to run some NetBeans modules

Complete error message: The JDK is missing and is required to run some NetBeans modules Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information. Some details: I…
1
2 3
92 93