Monday, 14 May 2007

Swing/NetBeans development impressions

 

I've never been a big desktop app developer.  I had heard from a number of people at JavaOne that Swing had become much easier to work with lately.  I had a friend who wanted me to port a simple C# desktop app to Java so I immediately jumped in to get a feel for desktop app programming again.

 

I had heard from a number of people that the Netbeans Matisse swing builder was a really good tool. I was not disappointed at all. I was able to whip up a quick copy of the application UI I was porting in Matisse and get it functioning and doing things rather quickly.

NetBeans as an IDE could use a bit of work though. Some things I found that weren't so great:

  • Quick fix support is much more primitive than in Eclipse.
  • The recompilation and error hilighting is not as fast as Eclipse.
  • Sometimes auto-complete would fail mysteriously.
  • The debugger doesn't let you change your code while your program is running.
On the other hand there were some things I liked about NetBeans:
  • Matisse is a great tool for making Swing apps.
  • I didn't have to download any plug-ins to get started.
  • The XML editor is pretty decent.
  • The build system is built in and a no brainer. You don't have to hack your own.
  • Performance and stability were better in NetBeans.
  • No need for perspective switching.
Overall it seems that Eclipse is a little Frankensteinish at times with so many plug-ins all trying to work together.  On the other hand, the base Eclipse Java Development Platform is exceptional.  I'm going to have to stick with Eclipse for now.  
Posted by justin at 10:39 PM in Java Programming

Saturday, 12 May 2007

Blojsom + Jetty + Postgres

Blojsom is a great java based blogging webapp that I got up and running today. 

Here's my guide as to how to set it up:

Setting up Blojsom 3.2 on Postgres/Jetty

  • Download Blojsom Quickstar Bundle

    http://sourceforge.net/project/showfiles.php?group_id=72754&package_id=125988

  • Download Jetty 6

    http://dist.codehaus.org/jetty/jetty-6.1.3.zip

  • If Postgresql has not been installed you can get it from:

    http://www.postgresql.org/

    if you are on Debian or Ubuntu simply run

    apt-get install postgresql
Now on to the install
  • from your home directory - assuming your site is called xclu.com:
    mkdir xclu.com 

    unzip jetty-6.1.3.zip

    declare -x JETTY_HOME=~/xclu.com/jetty-6.1.3/

    cd $JETTY_HOME

    Get the appropriate Postgresql driver from

    http://jdbc.postgresql.org/download.html

    to get your version

    psql --version

    copy it to $JETTY_HOME/lib/ext/

    cd webapps

    mkdir blojsom

    cd blojsom

    jar -xvf ~/xclu.com/blojsom.war

    edit $JETTY_HOME/webapps/blojsom/WEB-INF/classes/blojsom-helper-beans-include.xml

    Replace the datasource with an appropriate postgresql configuration. You probably want to use a better password than 'blojsom'.:



    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.postgresql.Driver"/>
    <property name="url" value="jdbc:postgresql://localhost/blojsom"/>
    <property name="username" value="blojsom"/>
    <property name="password" value="blojsom"/>
    </bean>

    Modify the dialect

    <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>

    Edit $JETTY_HOME/webapps/blojsom/WEB-INF/classes/blojsom.xml

    Modify the dbloader


    <bean id="dbloader" class="org.blojsom.util.database.DatabaseLoader" init-method="init">
    <property name="sessionFactory">
    <ref bean="hibernateSessionFactory"/>
    </property>
    <property name="dbScript" value="/WEB-INF/classes/blojsom-full-initial-data-postgresql.sql"/>
    <property name="upgrading" value="false"/>
    <property name="servletConfig">
    <ref bean="servletConfigFactoryBean"/>
    </property>
    <property name="detectBlojsomSQL">
    <value>select relname from pg_stat_user_tables where relname = 'blog';</value>
    </property>
    </bean>

    Create the blojsom database (may need to be done as postgres user account if you haven't created a postgres superuser account for yourself)

    createuser blojsom

    Answer no to whether the user should be allowed to create databases or other users

    createdb -O blojsom blojsom

    psql blojsom
    blojsom=# alter user blojsom with password 'blojsom';
    blojsom=# \q

    To allow local acess to your database edit pg_hba.conf and add the following line right underneath the IPv4 comment.

    # All IPv4 connections from localhost
    host blojsom blojsom 127.0.0.1 255.255.255.255 md5

    Restart postgresql

    Test the configuration

    psql -h 127.0.0.1 -U blojsom -W blojsom

    login with password "blojsom"

    You should get the follow prompt

    blojsom=>

    exit the psql client

    blojsom=> \q

    Set the hostname and port in $JETTY_HOME/etc/jetty.xml properly

        <Call name="addConnector">
    <Arg>
    <New class="org.mortbay.jetty.nio.SelectChannelConnector">
    <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
    <Set name="maxIdleTime">30000</Set>
    <Set name="host">www.xclu.com</Set>
    <Set name="Acceptors">1</Set>
    <Set name="statsOn">false</Set>
    <Set name="confidentialPort">8443</Set>
    <Set name="lowResourcesConnections">1000</Set>
    <Set name="lowResourcesMaxIdleTime">500</Set>
    </New>
    </Arg>
    </Call>

    Replace localhost:8080 with whatever your actual hostname is. In this case my hostname is 'www.xclu.com'

    Change the jetty sql scripts so they initialize the database with the right hostname

    perl -pi -e 's/localhost:8080/www.xclu.com/g' $JETTY_HOME/webapps/blojsom/WEB-INF/classes/*.sql

    Run Jetty!

    cd $JETTY_HOME
    ./bin/jetty.sh start

    Now go to

    • You may now access your blog at http://your-blojsom-install-site/blojsom/blog/default/
    • You may access the administration console at http://your-blojsom-install-site/blojsom/blog/default/?flavor=admin
    • The default user and password is default/default. Be sure to change the password immediately after logging in. You can change this under Weblog Settings | Users.

Technorati Tags:

Posted by justin at 11:51 PM in Java Programming
« May »
SunMonTueWedThuFriSat
  12345
6789101112
13141516171819
20212223242526
2728293031