random thoughts

Move Wordpress Blog From Root to Subdirectory

am quite sure you will get a lot of tutorials for this topic

try this http://www.google.co.in/search?q=move+wordpress+blog+from+root+to+su bdirectory

but that didn solve one particular problem,  redirecting the old url to new url.

earlier i had my blog in the root directory on my domain http://www.rajeshpg.com.i moved my blog to a subdirectory http://www.rajeshpg.com/blog.i reinstalled wordpress in the subdirectory,and import my earlier posts.

The problem is that the old url for a post (probably indexed by google) should be redirected to new url.

example:- http://www.rajeshpg.com/2007/01/javaxservletservletexception-path- loginlayout-does-not-start-with-a-character/ should be redirected to http://www.rajeshpg.com/blog/2007/01/javaxservletservletexception-path- loginlayout-does-not-start-with-a-character/

After googling for an hour i got the solution.

modify your .htaccess file(or create one) in the root directory with this code.

RewriteEngine On RewriteBase / RewriteRule ^(\d*)/(\d*)/(.*)$ http://yourdomainname.com/blog/$1/$2/$3 [L,R=301] (\d) represents a sequence of numbers. (.) represents sequence of characters.

note:- this solution works only for the urls of /year/month/title pattern of wordpress blog.

Desktop Java Application and Image Folders

I am developing a small desktop application using Java(ofcourse…).

Its a very long time that i had my hands on Swing.

First thing was to choose an IDE that will make the job more easier and this time i wanted to try

different IDE(i use Eclipse at work and at home too…), so i ended up with NetBeans.

NetBeans for Java desktop applications is like VisualBasic to Windows applications.

Everything was fine until i wanted to add an image to the title bar of a window(JFrame) .

Since this is a desktop java application, i thought to have the images folder inside the jar file.

Issues i faced
i created a folder with name images and put some images inside it.

Since Netbeans gives an ant build file to build and create a jar file , i had to edit the build.xml file to add the image folder inside myapp.jar file.

i tried my best to do it , but i couldn.

Solution
after creating the image folder , right-click on the project , select properties, click Add Folder and select the images folder.

images folder

Now Netbeans rewrites the build.xml file to add the images from the image folder to the jar.

so i edited the build.xml file ,so that the images are under a folder inside the jar.

before editing the build.xml the task was

<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre- compile" if="have.sources"> `` <j2seproject3:javac/>

<copy todir="${build.classes.dir}">

<fileset dir="${src.images.dir}" excludes="${build.classes.excludes}"/>

<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>

</copy> </target>

after editing the build.xml

<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre- compile" if="have.sources"> <j2seproject3:javac/> <copy todir="${build.classes.dir}"> <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> </copy> <copy todir="${build.classes.dir}/images"> <fileset dir="${src.images.dir}" excludes="${build.classes.excludes}"/> </copy> </target>

to load the image file to the title bar of the JFrame

public Image getIconImage() { ClassLoader cldr = this.getClass().getClassLoader(); java.net.URL imageURL = cldr.getResource("images/login.gif"); return new ImageIcon(imageURL).getImage(); }

setIconImage(getIconImage());

So thats the solution i found to refer to an image file inside images folder packed inside a jar file.

HOWTO Install , Configure and Run Resin Web Server in Ubuntu/Kubuntu

I wanted to try a new web server and learn to use it.

The webserver is Resin.lets try.

steps: Prerequisite: JDK 5.0 or later version.(i didn try with 1.4 , so i am not sure.) 1.Download Resin from Caucho .( ofcourse :) )

2.Unzip the .tar.gz file.( yes, for linux download the .tar.gz file)

3.Open a command prompt and navigate into the resin folder .

4.In the command prompt type ./configure

Resin configure

if u get an error ”checking for C compiler default output file name… configure: error: C compiler cannot create executables” .

the solution is

for Ubuntu/Kubuntu on 32 bit processor : instal glibc-devel.

for Ubuntu/Kubuntu on 64 bit processor : instal libc6-dev-amd64.

  1. in the command prompt type make (if your ./configure command was succesful.)

  2. in the command prompt type make install.

If everything goes fine till here then the installation of Resin web server is complete.

To start the server , in the command prompt navigate into the bin folder and the type the command ./httpd.sh.

Open your favourite web browser and type http://localhost:8080.You should get the welcome page.

If you get an error that “tools.jar is not in the classpath” , open resin.conf file placed inside conf folder and

replace the tag

<java compiler="internal" compiler-args=""/>;

with

<java compiler='javac'/>

This should solve the problem.

Restart the server and check in the web browser , you should get the welcome page.