Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

2014-11-06

How to disable SSLv3 on WildFly 8.1

SSL 3 is dead.
Because of POODLE attacks it is better security practice to disable SSLv3 and adopt only TLS. To disable SSLv3 on WildFly 8.1 set the enabled-protocols attribute of the https-listener node of the undertow subsystem in the wildfly configuration file (e.g. standalone.xml) accordingly:

<subsystem xmlns="urn:jboss:domain:undertow:1.1">
  <server name="default-server">
    <https-listener name="https" socket-binding="https" security-realm="SSLRealm" enabled-protocols="TLSv1,TLSv1.1,TLSv1.2"/>

Possible values for the enabled-protocols attribute in WildFly 8.1 are:

  • SSLv3
  • TLSv1
  • TLSv1.1
  • TLSv1.2
Multiple values can be separated by comma, e.g.:
enabled-protocols="TLSv1,TLSv1.1,TLSv1.2"

2014-08-20

Install JDK 8 manually on Windows

To install the JDK manually on a windows system:

  • Download the JDK Executable from Oracle
  • Extract the content of the installer exe to an empty folder (e.g. c:\jdk8)
  • Extract the extracted tools.zip into the same folder
  • Delete the tools.zip after successfull extraction 
  • Open a command line and change into the folder (cd c:\jdk8)
  • In the extraction directory execute (one line):
    for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
  • Set the JAVA_HOME environment variable if required

2013-12-13

JavaFX for iOS NetBeans Plugin available

For NetBeans 7.4 there is a plugin available for building JavaFX applications for iOS devices. The plugin uses RoboVM to translate Java byte-code to native ARM code.


It can be downloaded here: http://plugins.netbeans.org/plugin/52156/javafx-for-ios-project-support

2013-10-19

Install JDK 8 on Raspberry Pi

What you need:
  • Raspberry Pi (model B)
  • Raspbian installed
Install JDK 8:
  • Get Oracle JDK 8 (with JavaFX) for ARM from the Oracle download page: http://jdk8.java.net/download.html
    You need the Linux ARMv6/7 VFP, HardFP ABI version
  • Extract it to /opt/jdk1.8.0/ using:
    sudo tar zxvf jdk-8-ea-b*.tar.gz -C /opt
  • Setup Java
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/jdk1.8.0/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/jdk1.8.0/bin/javac" 1
If there is more than one java runtime installed check which version is used by output of:
java -version


If it is the wrong java runtime version, solve this by running:
sudo update-alternatives --config java
And choose the appropriate option.

2012-10-13

Java Connector Architecture (JCA) 1.6 and CDI on Glassfish 3.1

Context and Dependency Injection (CDI) is different if used in a Java Connector Architecture (JCA) 1.6 Resource Adapter.
If there is a beans.xml in the META-INF directory of a resource adapter (RAR), the beans.xml file is read and the resource adapter is recognized as a CDI module correctly.
This way CDI can be used for all beans inside the resource adapter.

But remember:
However it is not possible to inject CDI bean classes contained in a resource adapter RAR into other web applications or EJBs.

2011-06-18

Auto-Update for Java Applications

Java WebStart-Applications have a great update mechanism using JNLP. It checks during launch if there is a new version available on the server and downloads the new version to the client automatically. This way the client always runs with the latests version available on the server. But what about standalone Java applications?

Appcast - an RSS 2.0 update feed

Similar to podcasts a appcast is a RSS 2.0 feed to announce a new release of a software product. It basically uses standard RSS 2.0. The reference to the new version file can be specified in the enclosure tag:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
   <channel>
      <title>MyApp Changelog</title>
      <link>http://example.com/MyApp/appcast.xml</link>
      <description>Latest changes and updates.</description>
      <language>en</language>
      <item>
         <title>Version 1.3.2</title>
         <pubDate>Wed, 18 Jun 2011 09:20:11 +0000</pubDate>
         <enclosure url="http://example.com/MyApp-1.3.2.zip" length="1234567" type="application/octet-stream" />
      </item>
   </channel>
</rss>

Just place this as appcast.xml on some host that is accessible by the application. The application can check if there is a new update available using this appcast.xml.

Appcast Framework for Mac OS X

Andy Matuschak's Sparkle is a free software update framework for Mac OS X that is very widespread. It has some appcast extensions for custom version strings and DSA signature for the update file. An complete sparkle appcast example can be found here. With these extensions is also possible to include a link to the release notes file.

Appcast updates for Java Applications?

The RSS 2.0 structure is very easy and there are already java parsers available. The sparkle extensions can also be parsed in Java. You can use JAXB to get the values out of the enclosure tag:
@XmlAccessorType(XmlAccessType.FIELD)
public class Enclosure {
    @XmlAttribute
    String url;
    @XmlAttribute
    long length;
    @XmlAttribute
    String type;
    @XmlAttribute(namespace="http://www.andymatuschak.org/xml-namespaces/sparkle")
    String version;
    @XmlAttribute(namespace="http://www.andymatuschak.org/xml-namespaces/sparkle")
    String shortVersionString;
    @XmlAttribute(namespace="http://www.andymatuschak.org/xml-namespaces/sparkle")
    String dsaSignature;
...
The other tags can be processed the same way. You only need to compare the current application version string with the one from the appcast enclosure. If the appcast version is newer, download the update file.

But how do you handle applications with multiple JAR files if every component has it's own versioning? The version string from the MANIFEST.MF file can be used or one can add a new version string, e.g. 'Appcast-Version: 1.2.3', to the JAR's MANIFEST.MF file. This can be read easily at runtime with java.util.jar.Manifest class:
Manifest manifest = new Manifest(new FileInputStream(new File("manifest.mf")));
Attributes mainAttributes = manifest.getMainAttributes();
if (mainAttributes != null) {
   return mainAttributes.getValue("Appcast-Version");
}

The appcast URL itself can also be placed inside the MANIFEST.MF file for each application module, e.g. using "Appcast-Url: http://example.com/MyApp/appcast.xml".

Keep in mind that it is not possible to replace a JAR file of a currently running application. So you need a bootstrap mechanism to check and download updates and apply them during next start of the application.