java-7

Java 7 prevents FTP transfers on Windows Vista and 7 if firewall is on. Any ideas?

橙三吉。 提交于 2019-11-26 17:55:32
问题 Java 7 prevents FTP transfers on Windows Vista and 7. In FTP, before a file is transferred a PORT or a PASV command must be sent. As soon as one of the commands is sent the Windows Firewall closes the socket that sent it. This only happens if the firewall is on and an exception for java.exe is absent. I suspect this problem is related to Java 7 using the new Vista IP stack. Does anyone have any ideas how to fix or work around this problem? We're distributing a Java FTP library so we obviously

Java Thread priority has no effect

六月ゝ 毕业季﹏ 提交于 2019-11-26 17:53:20
This is a test about thread priority. The code is from Thinking in Java p.809 import java.util.concurrent.*; public class SimplePriorities implements Runnable { private int countDown = 5; private volatile double d; // No optimization private int priority; public SimplePriorities(int priority) { this.priority = priority; } public String toString() { return Thread.currentThread() + ": " + countDown; } public void run() { Thread.currentThread().setPriority(priority); while (true) { // An expensive, interruptable operation: for (int i = 1; i < 10000000; i++) { d += (Math.PI + Math.E) / (double) i;

Java 7 String - substring complexity

故事扮演 提交于 2019-11-26 17:49:30
Until Java 6, we had a constant time substring on String . In Java 7, why did they decide to go with copying char array - and degrading to linear time complexity - when something like StringBuilder was exactly meant for that? Why they decided is discussed in Oracle bug #4513622 : (str) keeping a substring of a field prevents GC for object : When you call String.substring as in the example, a new character array for storage is not allocated. It uses the character array of the original String. Thus, the character array backing the the original String can not be GC'd until the substring's

How to enable TLS 1.2 in Java 7

荒凉一梦 提交于 2019-11-26 17:43:02
I am trying to enable TLS 1.2 in my web app which uses JBoss 6.4 and Java 1.7. I have -Dhttp.protocols = TLSv1.2 in my application environment but it doesn't seem to work for me. Is there anything I could do to enable TLS 1.2? I wrote a simple program context = SSLContext.getInstance("TLSv1.2"); context.init(null,null,null); SSLContext.setDefault(context); SSLSocketFactory factory = (SSLSocketFactory)context.getSocketFactory(); SSLSocket socket = (SSLSocket)factory.createSocket(); protocols = socket.getEnabledProtocols(); After running this program within the app the TLS 1.2 gets enabled. I do

In a Java 7 multicatch block what is the type of the caught exception?

我的梦境 提交于 2019-11-26 17:34:15
问题 In a Java 7 multicatch block such as the following: try { // code that throws exception } catch (CharacterCodingException | UnknownServiceException ex) { // handle exception } what is the compile-time type of ex ? Is it the most derived class that both exception types have in common? In this example that would be an IOException . 回答1: Yes, the type of ex is the most specific supertype of both CharacterCodingException and UnknownServiceException , which would be IOException . Edit: Straight

Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?

只愿长相守 提交于 2019-11-26 17:13:10
问题 Here's the example. If you build and run TranslucentWindow in let's say, NetBeans IDE 7.0, which supports jdk7, you'll get the following exception: Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated at java.awt.Frame.setOpacity(Frame.java:960) at main.TranslucentWindow.<init>(TranslucentWindow.java:23) at main.TranslucentWindow$1.run(TranslucentWindow.java:47) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) at java.awt

changing eclipse's java compiler to jdk7 [duplicate]

亡梦爱人 提交于 2019-11-26 16:45:27
问题 This question already has answers here : how do I get eclipse to use a different compiler version for Java? (4 answers) Closed 5 years ago . I'm trying to upgrade from jre6 and jdk6 to jre7 and jdk7. I program using eclipse, i downloaded and installed the jre7 and jdk7 on: C:\program files\java\ now when I enter eclipse i want to change the used compiler so i go to: window>preferences>java>compiler but there appears only 1.3,1.4,1.5 and 1.6 I've also entered: window>preferences>java>Installed

Android import java.nio.file.Files; cannot be resolved

强颜欢笑 提交于 2019-11-26 16:35:41
I am trying out the new Gmail API and the samples use the classes in the java.nio.file package, e.i. Files and FileSystems . These classes was introduced in Java jdk 1.7 for the record, and since I am running jdk 1.7.0_65 in my Android app I have no idea why Android Studio cannot find these classes. The imports are: import java.nio.file.FileSystems; import java.nio.file.Files; My build.gradle file of course tells the system to use v. 1.7 like this android { compileSdkVersion 19 buildToolsVersion '20' ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility

Why is my URI not hierarchical? [duplicate]

心不动则不痛 提交于 2019-11-26 16:32:05
This question already has an answer here: Java Jar file: use resource errors: URI is not hierarchical 6 answers I have files in resource folder. For example if I need to get file from resource folder, I do like that: File myFile= new File(MyClass.class.getResource(/myFile.jpg).toURI()); System.out.println(MyClass.class.getResource(/myFile.jpg).getPath()); I've tested and everything works ! The path is /D:/java/projects/.../classes/X/Y/Z/myFile.jpg But , If I create jar file, using , Maven : mvn package ...and then start my app: java -jar MyJar.jar I have that following error: Exception in

“Comparison method violates its general contract!” - TimSort and GridLayout

血红的双手。 提交于 2019-11-26 16:11:02
I made a color palette with a jPanel and a JLabel array in it. At first it worked well, but then i put some other jLabels out of the JPanel and added them some events. Now I keep getting this error: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.TimSort.mergeLo(TimSort.java:747) at java.util.TimSort.mergeAt(TimSort.java:483) at java.util.TimSort.mergeCollapse(TimSort.java:410) at java.util.TimSort.sort(TimSort.java:214) at java.util.TimSort.sort(TimSort.java:173) at java.util.Arrays.sort(Arrays.java:659)