Archive for the ‘Ubuntu’ Category.

Tomcat multiple instances on Linux, Ubuntu / Mint

I was trying to figure out how to run multiple instances of Tomcat6 the other day on my Mint Linux. After a bit of searching and poking around I came to a very slick solution. But it took a while to find it, so I figure I will share the quick and dirty here, to get you up going quickly if your searching for the same.

Lets go through the whole thing, install Tomcat6
>sudo apt-get install tomcat6

You might have to set your java path if not set already, for example
>export JAVA_HOME=/usr/java/jdk1.6.0/bin/java
To check the setting
>echo $JAVA_HOME

You probably want to install the examples as well, just to mae sure things are working servlets, jsp etc,
>sudo apt-get install tomcat6-examples

If all is well as you would fully expect, you can start your Tomcat
>sudo sh /etc/init.d/tomcat6 start

And in return you will be able to access your tomcat in your browser at
http://localhost:8080

So lets take a look at how to configure multiple instances on the same linux box. Go to a directory where you want your new tomcat instance located. Then you do something like this
>tomcat6-instance-create myInstance

This will create a new directory called myInstance which will host your new instance of Tomcat. It will have it’s own configuration files, logs, etc. The first thing you probably want to do is to go to the config directory and change the ports in the server.xml file. Once you have the ports changed from the usual 8080 you can start your instance from /myInstance/bin directory.
>sh startup.sh

Just as you would with any other instance of Tomcat and shut down with the shutdown.sh script. Next time you need another instance on another port just create a new one
>tomcat6-instance-create myInstance_8030
and so on and so forth.

All the details can be found in the Ubuntu documentation.

Adobe Air development

I was talking to a friend about lack of a good interface for discovering NetFlix movies that do actually stream. The problem is that most of the movies are DVD distribution only. Further the streaming movies are sometimes streaming and sometimes not. It has something to do about when they are showing on TV. If your like me, you want to watch your movie at the end of the day when there is nothing on TV. In that case you want it streaming right there and then.

So I figure why not create a small app that will keep a list of the movies your wanting to see and it should be able to refresh and show you which ones are available for NetFlix streaming at any given time. Sounds easy enough, but there is a catch, I wanted it cross platform as my friend mostly uses a Mac. Hmm so I was thinking that’s easy enough just create simple C# program that will run smoothly on Mac under Mono. No that’s too easy, then it came to me, I have wanted to look at Adobe Air apps, this is a perfect opportunity. Let’s give it a try, as added bonus I wanted to do some dev on my Linux box. It should be fun to create this little app on the Linux and have it run on PC and Mac as well.

Well it turns out that Adobe only supports the FlashBuilder on Win and Mac, no Linux for you my friend. But we don’t give up that easily, I don’t want to run under Wine, turn to google and I find Fb4Linux. As it turns out after installing a bunch of libs and the FlashBuilder and some Sdks and such that I couldn’t get it to run under Linux ( I might try again later ). I’m probably not running the same versions of stuff as the author of the instructions, or maybe I just can’t follow instructions that well. Oh well, back to Windows, get the install from Adobe and it installs fine, then run the IDE, it plugs into Eclipse. Sure enough nothing to be found there, but wait a minute, not only do they ( claim to ) install it as plugin in your existing Eclipse, they also install a whole new instance of Eclipse. Sure enough when I run that new instance FB comes up and works as expected, you can start a new FB project etc.

Now with all the install trouble out of the way let’s give it a spin. File -> New Flex Project, the basics are setup for you by the wizard. Drag a couple of controls on the panel, goto properties and create click event for the button, there you have it “Hello World” Then click export, go through the wizard and an .air install file has been created. That’s pretty nice considering that I didn’t read any quick starts tutorials. But wait a minute, I click the air file to run it on my desktop and get some error indicating corrupted Air install file, contact the provider for a new file etc. Google search to the rescue and after un-installing and re-installing Air, nothing had changed. Then I uncheck the option of having a Timestamp in the digital signature of the .air file and that did the trick, now I can run and install, uhh.

Things seem to be looking up, time to code this puppy….. when I get to it, not sure if I’m going to pursue that or not, might be a follow up post. Notice all the javascript, might be too web-ish for my taste.

Here is Hello World in code

<?xml version=“1.0” encoding=“utf-8”?>
<s:WindowedApplication xmlns:fx=“http://ns.adobe.com/mxml/2009”
                                           xmlns:s=“library://ns.adobe.com/flex/spark”
                                           xmlns:mx=“library://ns.adobe.com/flex/mx”>

                <fx:Script>
                <![CDATA[
                        import mx.events.FlexEvent;
                       
                        protected function button1_clickHandler(event:MouseEvent):void
                        {
                                txSome.text = “Hello World !”;
                        }
                ]]>
        </fx:Script>

        <fx:Declarations>
                <!– Place non-visual elements (e.g., services, value objects) here –>
        </fx:Declarations>
        <s:Button x=“37” y=“10” label=“Button” click=“button1_clickHandler(event)”/>
        <s:TextArea x=“37” y=“52” id=“txSome”/>
</s:WindowedApplication>

And the app itself

Update
—–
I got Flex builder working later on the Linux box after some tinkering, that’s how the sample looks there.