Java 7 Automatic Resource Management JDBC (try-with-resources statement)

try(Connection con = getConnection()) { try (PreparedStatement prep = con.prepareConnection(“Update …”)) { //prep.doSomething(); //… //etc con.commit(); } catch (SQLException e) { //any other actions necessary on failure con.rollback(); //consider a re-throw, throwing a wrapping exception, etc } } According to the oracle documentation, you can combine a try-with-resources block with a regular try block. IMO, … Read more

java.security.cert.CertificateException: Certificates does not conform to algorithm constraints

Background MD2 was widely recognized as insecure and thus disabled in Java in version JDK 6u17 (see release notes http://www.oracle.com/technetwork/java/javase/6u17-141447.html, “Disable MD2 in certificate chain validation”), as well as JDK 7, as per the configuration you pointed out in java.security. Verisign was using a Class 3 root certificate with the md2WithRSAEncryption signature algorithm (serial 70:ba:e4:1d:10:d9:29:34:b6:38:ca:7b:03:cc:ba:bf), … Read more

How to set IntelliJ IDEA Project SDK

For a new project select the home directory of the jdk eg C:\Java\jdk1.7.0_99 or C:\Program Files\Java\jdk1.7.0_99 For an existing project. 1) You need to have a jdk installed on the system. for instance in C:\Java\jdk1.7.0_99 2) go to project structure under File menu ctrl+alt+shift+S 3) SDKs is located under Platform Settings. Select it. 4) click … Read more

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

Right from the JavaDocs for java.awt.frame.setOpacity() in JDK7: The following conditions must be met in order to set the opacity value less than 1.0f: The TRANSLUCENT translucency must be supported by the underlying system The window must be undecorated (see setUndecorated(boolean) and Dialog.setUndecorated(boolean)) The window must not be in full-screen mode (see GraphicsDevice.setFullScreenWindow(Window)) If the … Read more

How do I use JDK 7 on Mac OSX?

This is how I got 1.7 to work with Eclipse. I hope it helps. I Downloaded the latest OpenJDK 1.7 universal (32/64 bits) JDK from Mac OS/X branch from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html copied the jdk to /Library/Java/JavaVirtualMachines/ next to the default 1.6.0 one In Eclipse > Preferences > Java > Installed JREs you add a new one, … Read more