Close resource quietly using try-with-resources

I found this answered on the coin-dev mailing list: http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001503.html 5. Some failures of the close method can be safely ignored (e.g., closing a file that was open for read). Does the construct provide for this? No. While this functionality seems attractive, it is not clear that it’s worth the added complexity. As a practical … Read more

javafx 8 compatibility issues – FXML static fields or methods

It sounds like you are trying to inject a TextField into a static field. Something like @FXML private static TextField myTextField ; This apparently worked in JavaFX 2.2. It doesn’t work in JavaFX 8. Since no official documentation ever supported this use, it’s doesn’t really violate backward compatibility, though in fairness the documentation on exactly … Read more

Strange text wrapping with styled text in JTextPane with Java 7

for futures readers, bug is still present in JDK 1.7.0_04., comparing Java7 and with stable Java6, <—— Java7 v.s. Java6 —> <—— Java7 v.s. Java6 —> <—— Java7 v.s. Java6 —> <—— Java7 v.s. Java6 —> from code import java.awt.Dimension; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; public class BugWrapJava7 { private JFrame frame = new … Read more

com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded

I had the same issue while I was trying to dump threads using jcmd. I was getting same error message even though I was running jcmd under the root user. You need to run jcmd <pid> Thread.print under the same user as java process has, otherwise your connections will be dropped. Java doesn’t care if … Read more

Sending email using JSP

Well offhand I would say there is an authentication issue when trying to connect. You are not providing any username or password, unless your exchange server doesn’t require username and password. UPDATE: If using JDK 7 see the following post, it resolved this issue: Defect – JDK7 Permission Denied with Sockets when using VPN “More … Read more

Having spaces in Runtime.getRuntime().exec with 2 executables

Each argument you pass to the command should be a separate String element. So you command array should look more like… String[] a = new String[] { “C:\path\that has\spaces\plink”, “-arg1”, “foo”, “-arg2”, “bar”, “path/on/remote/machine/iperf -arg3 hello -arg4 world”}; Each element will now appear as a individual element in the programs args variable I would also, … Read more

How to set a java compiler in Netbeans

Right click on your project –> Project Properties Then in Sources set Source/Binary Format to JDK 7. EDIT 1 : There is a NetBeans issue: Works fine in J2SE project, Web project specific problem. The problem is that fork=”false” the JDK 7.0 params are passed to JDK 6.0 compiler. The executable requires fork=”true”. On the … Read more

Enable TLSv1.2 and TLS_RSA_WITH_AES_256_CBC_SHA256 Cipher Suite

It is only possible if you use a simple HTTPS connection (not SSL Sockets) using the properties -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_RSA_WITH_AES_256_CBC_SHA256 See the post at http://fsanglier.blogspot.com.es/ Java 7 introduced support for TLS v1.2 (refer to http://docs.oracle.com/javase/7/docs/technotes/guides/security/enhancements-7.html) BUT does not enable it by default. In other words, your client app must explicitly specify “TLS v1.2” at SSLContext creation, … Read more