Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Sunday, August 26, 2007

Screen capture in Intel Mac OS X 10.4






Command + Shit + 3

Capture the full screen

Command + Shit + 4
Capture the part of screen

Command + Shit + 4 + Space
Capture any one of windows

Using SQLite with Java on Intel Mac OS X


Step 1:
Click here to Download the SQLite Mac OS X 10.4 JNI wrapper (thanks Tim Anderson)

Step 2:
Extract the sqlite_jni.macosx.zip file; and copy these 2 files into the /Library/Java/Extensions folder
- libsqlite_jni.jnilib
- sqlite.jar

Step 3:
compile the test.java file that come with the zip file
> javac test.java

Step 4:
run it with "java test", you will found these exception message

Unable to load sqlite: java.lang.UnsatisfiedLinkError: /Library/Java/Extensions/libsqlite_jni.jnilib:
Exception in thread "main" java.lang.UnsatisfiedLinkError: version
at SQLite.Database.version(Native Method)
at test.main(test.java:72)

Friday, August 10, 2007

Fix the chinese encoding problem in the AppFuse generated application

Using the AppFuse on Mac OSX, you will find the default generation of an application couldn't display the Traditional Chinese / Simplified Chinese as normal like this.

Sunday, May 13, 2007

Fix AppFuse generated application that couldn't connect HSQLDB database

Step 1: Enable the hibernate show sql features. This for tracing which SQL have problem to execute. If the 1st one has problem, we can going on.

Step 2: Since, the original AppFuse 1.9.x is not well prepare for the HSQLDB. We need to prepare the table creation script for the HSQLDB. i.e., hsql-create.sql, in the metadata folder of the project generated by the AppFuse.


Step 3: Using command "ant db-prepare" or click it the "db-prepare" to execute it in the Ant view of the Eclipse.


Step 4: Using command "ant compile" or click the "compile" in the Ant view of Eclipse.

Step 5: Using command "and deploy-war" or click the "deploy-war" in the Ant view of Eclipse.

Saturday, May 12, 2007

java.net.BindException: Address already in use:8080

After several times to reload the deployed application in tomcat on Mac OSX. I found the tomcat fail to start with this exception messages.

2007/5/12 下午 01:17:44 org.apache.coyote.http11.Http11BaseProtocol start
嚴重的: Error starting endpoint
java.net.BindException: Address already in use:8080
at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoint.java:297)
at org.apache.tomcat.util.net.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java:312)
at org.apache.coyote.http11.Http11BaseProtocol.start(Http11BaseProtocol.java:150)
at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:75)
at org.apache.catalina.connector.Connector.start(Connector.java:1089)
at org.apache.catalina.core.StandardService.start(StandardService.java:459)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2007/5/12 下午 01:17:44 org.apache.catalina.startup.Catalina start
嚴重的: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1096)
at org.apache.catalina.core.StandardService.start(StandardService.java:459)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2007/5/12 下午 01:17:44 org.apache.catalina.startup.Catalina start

It's obviously that there has another process occupied the port 8080 or 8009. I uses the command, "lsof -i | grep LISTEN" to check the PID of the process that using the port.

imachome:/usr/local/apache-tomcat-5.5.20/logs chanapps$ lsof -i | grep LISTEN
java 298 chanapps 11u IPv6 0x2e2e3a0 0t0 TCP *:http-alt (LISTEN)
java 298
chanapps 18u IPv6 0x2e2ec50 0t0 TCP *:8009 (LISTEN)

And then, kill the process with "kill -9 298" command. Now, the tomcat recover!

Tuesday, May 08, 2007

Eclipse plugins for HSQLDB

When I trying to compare and select between HSQLDB and Apache Derby as the database for my mini application.

I found the Apache Derby has an interesting Eclipse Plugins can help to start and stop the Derby easily.

It caused me going to check any similiar plugins for HSQLDB. Finally, i found a project in source forge web site. I'm exciting and start to try it. However, it disappointed me that the plugins seems couldn't be uses directly extract to the eclipse plugins directory.

I had to agree that i like HSQLDB much more than Derby (just feeling). So, I try to fix it and have this workable version even the official project site is not active since 2004.

This plugin is good and easy enough for development.

You can add nature of HSQLDB in your project by right click on the project and select "HSQLDB > Add Database Engine nature"


And then, start / stop the HSQLDB for your project by right click on the project like this.


If you are interesed about it, just following these procedures to install it in your Eclipse.

1. download it from here

2. cd to ECLIPSE_HOME/plugins/

3. extract the hsqldb eclipse plugins.zip contents in the directory. The "hsqldb.ui" and "hsqldb.core" directories should be extracted into the ECLIPSE_HOME/plugins/ direcotry, like this:

ECLIPSE_HOME/plugins/hsqldb.ui/
ECLIPSE_HOME/plugins/hsqldb.core/

And then, the next time you start Eclipse, everything should work.

Thursday, April 26, 2007

Configure the HSQLDB server to store data in datafile

After you started the HSQLDB in server mode, it stores the data in memory by default. You have necessary to amend the properties file to change the hsqldb.default_table_type value to use cached as below.

With reference to my previous article, the property file name should be, "My-db.properties".

hsqldb.default_table_type=cached

Wednesday, April 25, 2007

Start HSQLDB server in my eclipse project folder

After successfully created my first application with AppFuse on MacOSX, I'm wonder how to make it work work with HSQLDB.

I found this wiki reference is really good as it simple but detail enough for the setup. I put this command in a file with the following contents; and then name it as "startHSQLDB.sh".

java -cp ~/dev/hsqldb/lib/hsqldb.jar org.hsqldb.Server -database.0 ./My-db -dbname.0 MyDB

Then, I change it's execution mode to 755 with following command.

> chmod 755 startHSQLDB.sh

Now, i can start it anytime when i need to have the development.

Sunday, April 22, 2007

Setup environment variable for the AppFuse on MacOSX

Edit the ".bash_login" file and add these environment variables before use start to use 'ant new' with Appfuse.

export CATALINA_HOME=/usr/local/apache-tomcat-5.5.20
export ANT_HOME=/Developer/Java/Ant

And then, copy the "junit.jar" file from the "lib/junit3.8.1/" folder inside the AppFuse directory to the ANT home "lib" folder.

And then, you can start to new a project with the "ant new" command. Just enter 3-4 simple information. Your application is created.

Using AppFuse in Mac OSX

Software development, Java programming ... etc. are keeping evolution and growth. Inside there, it has many compartively dummy and repeadly works. Why it is comparively dummy? It is simple under a condition, that is "You have experince to use it".

I always thinks how to avoid this kinid of works. Now, i'm trying a framework + tool, Appfuse 1.9.4. It seems can help to start a java web-based application in a short time. This is some of my experince of using it on Mac OSX.

Sunday, April 15, 2007

Hibernate No CurrentSessionContext configured!

Exceptionn message : "Hibernate No CurrentSessionContext configured!"

This message happened because didn't well configure the "hibernate.cfg.xml" file when using the "getCurrentSession()" function of the Hibernate session factory

Need the following property define in the hibernate.cfg.xml :

thread

XML Master Cert Group

Google Groups
XML Master Certification
Visit this group