The JavaDude Weblog

December 4, 2011

First hands-on Oracle Solaris 11

Filed under: tutorial — devdude @ 9:46 am
Tags: , , , , , , , , ,

After Oracle took over SUN and they dropped OpenSolaris I stopped using or even looking at it. Now a customer is keen on going the Solaris way and I have a chance to get my hands on it (again). I dont have a SUN SPARC sitting here but Oracle continues to support i386 architecture and they have both the iso file with the text installer and  even a ready to run virtual appliance ready to download (link). Oracle released version 11 of Solaris on 2011 November 9. Did you know SUN’s first OS goes back to 1982 as Sun UNIX 0.7 ?

I am not sure what happen to Solaris Express 11 which disappeared completely from Oracle’s website. Will there be another Express version for “free”/development/evaluation use ?

(more…)

November 25, 2011

ZK goes EC2 (Part 3)

Filed under: amazon aws,tutorial,zk — devdude @ 9:44 pm
Tags: , , , , , , , , , , ,

The third part of the tutorial where I improve a few things. I will not walk through the complete code but highlight a few important points and give you the complete sourcecode at the end.

To recap, my requirements:

  • I want to allow users in my company to start and stop instances on their own without them login to AWS console.
  • Only specific instances are available to them.
  • Avoid using elastic IP’s (you pay for them if they are not assigned)
  • Make it configurable

The improvements in this version:

  • Remove the hardcoded access keys and place them encrypted in a properties file.
  • Only instances that are not protected can be started or stopped.
  • Update DynDNS entries from the application
  • Some cosmetic cleanup of the control panel

(more…)

November 18, 2011

Remote Glassfish V3.1 and the mystical JMX settings

Filed under: glassfish,tools,tutorial — devdude @ 4:12 pm
Tags: , , , , ,

Once you have any serious sized application running on Glassfish, you need to profile and tune your server settings. A good tool to look under the hood of a running Glassfish is to to connect jconsole (part of JDK) to its JVM. This works without problem for a local Glassfish but when it comes to a remote instance you cant connect to the default Glassfish setup.

Lets look at the default setup

Glassfish Admin Console

(more…)

November 4, 2011

Netbeans + Visual Paradigm = EJB Tutorial (Part 3)

In part 1 of this tutorial we created an EJB using Netbeans and Visual Paradigm, in part 2 a little ZK application to read data using the EJB. In part 3 we will move away from the Derby DB to PostgreSQL and Oracle DB and challenge ourselves with identifier more than 30 characters, which is an issue for Oracle (yes, it is 2011). We will add columns with more than 30 characters and play with a few different column types (the ones showing up in a normal DB layout).

  • Add new fields to the ERD
    this_is_a_very_long_remark_field
    floatcol
    numbercol

    Updated ERD

  • (more…)

ZK and the clipboard

Filed under: tutorial,zk — devdude @ 5:21 pm
Tags: , , ,

 

Sounds too simple and it is present at a lot of websites: Copy to clipboard
I never had the requirement to copy text from a website to the clipboard, like you get the git URL when you are on a GIT project website and click the little icon. Same if you hover over the sourcecode below, you will get a copy option.

github.com

No, it is not possible to use simple javascript because it cant access your clipboard and you have no other chance then using one of the flash movie based solutions, like zeroclipboard, maybe one of the most popular ones.
The usual question: How do I get this embeded into my ZK web application ?

Short Tutorial:

  • Download the latest tar from code.google.com
  • Download the latest jQuery from jquery.com
  • Create a simple ZK web application
  • Place the jquery and zeroclipboard files into your Web Pagesfolder

    required files

  • Modify the index.zul file
    <?xml version="1.0" encoding="UTF-8"?>
    <zk xmlns="http://www.zkoss.org/2005/zul">
    
        <window id="info" apply="controller.indexController">
           <script src="jquery-1.6.4.js" type="text/javascript" />
           <script type="text/javascript" src="ZeroClipboard.js"/>
    
            <div id="d_clip_container">
                <image src="/Clipboard.png" />
            </div>
    
            <textbox id= "txtClipText"   cols="50" readonly="true" value="Some string for the clipboard"/>
    
            <script>
    		var clip = null;
    
    		function $(id) { return document.getElementById(id); }
    
                    function init(divId,clipText) {
                        ZeroClipboard.setMoviePath("ZeroClipboard.swf");
                        var clip = new ZeroClipboard.Client();
    
                        clip.addEventListener('mouseOver', function (client) {
                            clip.setText(zk.Widget.$(jq("$txtClipText")).getValue() );
                            //clip.setText(clipText);
                        });
    
                        clip.addEventListener('complete', function (client, text) {
                            alert("Copied text to clipboard: \n\n" + text );
                        });
    
                        clip.glue(divId);
    		}
            </script>
            <textbox value="" cols="30"/>
        </window>
    </zk>
    

    Remarks:

    • Using clip.setText(zk.Widget.$(jq(“$txtClipText”)).getValue() ); you can access a ZK textbox on the same page
    • With clip.setText(clipText); you can pass a text from the controller
  • Create a controller class
    package controller;
    
    import org.zkoss.zk.ui.Component;
    import org.zkoss.zk.ui.util.Clients;
    import org.zkoss.zk.ui.util.GenericForwardComposer;
    import org.zkoss.zul.Div;
    import org.zkoss.zul.Image;
    
    public class indexController extends GenericForwardComposer {
    
        Div d_clip_container;
        Image imgClipboard;
    
        @Override
        public void doAfterCompose(Component comp) throws Exception {
            super.doAfterCompose(comp);
    
            String command = "init('" + d_clip_container.getUuid() + "','some Text from controller');";
            Clients.evalJavaScript(command);
    
        }
    
    }
    
  • Run the application

    Running web application

 

Remarks:

  • Thanks to my team to get this running :-)
  • Most of it we learned by tinkering with the sample code from zeroclipboard.
  • I dont favor Flash solutions because we depend on Adobe's policies and changes. While Flash 9 allow reading and writing the clipboard easily, they consider it as a security risk in Flash 10. And only the trickery above makes it work. We wont know what Adobe will do in future versions, the above solution might break.

November 1, 2011

Amazon S3 plugin for Jenkins CI

Filed under: amazon aws,jenkins,tutorial — devdude @ 9:53 pm
Tags: , , , , , ,

About one year back I found this plugin, that saves your build artifacts to Amazon S3 storage. Unfortunately the plugin does not properly work with the current Jenkins versions and the original plugin is not maintained. Luckily someone forked and updated the plugin at github. You need to build the plugin by yourself with the help of maven, you still can refer to my original post, just one change is required to make it work, the settings for your ~/.m2/settings/xml need to be changed according to the plugin page description. Please be patient, maven is going to download a lot !

<settings>
 <pluginGroups>
 <pluginGroup>org.jenkins-ci.tools</pluginGroup>
 </pluginGroups>

 <profiles>
 <!-- Give access to Jenkins plugins -->
 <profile>
 <id>jenkins</id>
 <activation>
 <activeByDefault>true</activeByDefault> <!-- change this to false, if you don't like to have it on per default -->
 </activation>
 <repositories>
 <repository>
 <id>maven.jenkins-ci.org</id>
 <url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
 </repository>
 </repositories>
 <pluginRepositories>
 <pluginRepository>
 <id>maven.jenkins-ci.org</id>
 <url>http://maven.jenkins-ci.org/content/groups/artifacts/</url>
 </pluginRepository>
 </pluginRepositories>
 </profile>
 </profiles>
</settings>

Otherwise you get errors like

[INFO] Scanning for projects...
Downloading: http://download.java.net/maven/2/org/jenkins-ci/plugins/plugin/1.434/plugin-1.434.pom
[INFO] Unable to find resource 'org.jenkins-ci.plugins:plugin:pom:1.434' in repository java.net2 (http://download.java.net/maven/2)
Downloading: http://repo1.maven.org/maven2/org/jenkins-ci/plugins/plugin/1.434/plugin-1.434.pom
[INFO] Unable to find resource 'org.jenkins-ci.plugins:plugin:pom:1.434' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

October 31, 2011

Netbeans + Visual Paradigm = EJB Tutorial (Part 2)

Filed under: netbeans,tutorial,zk — devdude @ 4:00 pm
Tags: , , , , , , ,

In part 1 of this tutorial we walk through the modeling and code creation of an EJB using Netbeans and Visual Paradigm. In part 2 we will create a simple sample ZK web application that reads data using the EJB.

Prerequisites:

  • The project from completed tutorial part 1

Tutorial:

  • Create web application ‘demoejbweb’

    Create web application

    (more…)

ZK goes EC2 (Part 2)

Filed under: tutorial,zk,amazon aws — devdude @ 10:25 am
Tags: , , , , , , , , , ,

Part 1 of this tutorial we concluded with an web application that displays all our instances and their status. In this part we will add some more features to control our instances.

Prerequisites:

  • The project and environment from part 1

Tutorial (complete sourcecode at the end):

  • Display the region endpoints and allow to select different one
    We hardcoded our endpoint in the first version, if you run instances across the globe in the various AWS datacentres (US, Ireland, Singapore, Tokyo) we need to switch the endpoint easily.
    Lets add one more listbox, that we hide in a ZK popup (we could use a combo listbox, but for the sake of playing with all the available ZK components I use the popup). Same concept add a listbox in the zul and a EC2 region list and a list model with customer renderer in our controller. (more…)

October 28, 2011

Netbeans + Visual Paradigm = EJB Tutorial

Filed under: netbeans,tutorial — devdude @ 4:50 pm
Tags: , , , , , , ,

The only commercial product in my toolbox is Visual Paradigm, a professional UML and modeling tool that integrates with the Netbeans IDE. If you are sincere about ERD, Use-Case and class models you should look at it. The available Netbeans plugins for UML could not convince me yet, too simple (but free). Visual Paradigm seems to operate at the other end, looks rather overloaded with functionality, but once you know what you want and where the function is located, you can create a nice workflow.

In this tutorial (created for internal purpose) I share the steps to create an EJB and  the ERD model and let VP (Visual Paradigm) create the class source code for me.

Requirements:

  • Netbeans 7.x
  • Visual Paradigm (Professional Version)
    You can download the 30 days trial, the free community edition is not sufficient.

Tutorial Part 1:

  • Create EJB module ‘demoejb’

    New EJB module

    (more…)

October 27, 2011

d3.js Tree: most simple sample

Filed under: d3.js,tutorial — devdude @ 2:41 pm
Tags: , , , , , , ,

Learning d3.js might not be as easy as some other tools because there are no step-by-step instructions to get started on a hello-world level. The samples on the d3.js site are bit too complex for a noob. But browsing through the example folder of the d3.js download helps, and usually you learn most dissecting by re-assembling sample code from other people. Another great source is gist.github.com, a code snippet repository. Look for d3.js ! With bl.ocks.org you can even “run” the snippets.

The treeview is a classic visualization but one of my favorites, specifically if you spice it up with interaction and allow the user to dive into a subtree of his choice. But what is the most simple tree layout ? I want to understand the physics behind it. So let me share my compiled (of different samples) most simple version without any fancy features or interaction.

Simlpe Tree Layout

Here my bl.ocks.org version with code or here to copy and paste:

(more…)

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.