Month: January 2012

  • How to start Android adb server on startup in Ubuntu Linux from root

    How to start Android adb server on startup in Ubuntu Linux from root

    Hi, recently to make debug on real device I need to restart my adb server (Android Debug Bridge) manually.

    To use it I need restart it with root privileges.

    sudo adb kill-server
    sudo adb start-server

    Now I want to show you how to make it on startup your Linux OS.
    1. Create file with adb name
    2. Put it in /etc/init.d/ dir
    3. Add folowing content:

    #!/bin/sh
    case "$1" in
    start)
    # Start daemon.
    echo -n "Starting ADB: "
    /opt/android-sdk-linux/platform-tools/adb start-server
    ;;
    stop)
    # Stop daemons.
    echo -n "Shutting ADB: "
    /opt/android-sdk-linux/platform-tools/adb kill-server
    ;;
    restart)
    $0 stop
    $0 start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    esac
    
    exit 0

    4. Run following commands

    cd /etc/init.d/
    sudo chown root:root adb
    sudo update-rc.d adb defaults
    sudo chmod +x adb

    5. reboot your Linux OS
    6. Plug your Android device to USB
    7. run

    adb devices

    8. Everythink is ok If you see something like this:

    List of devices attached
    YOUR_DEVICE_SERIAL_NUMBER device

    Enjoy codding!

  • How to use Xeger lib with maven

    How to use Xeger lib with maven

    It will be useful for you if you need to get text which can be match with your existing regular expression in JAVA.

    Recently a had same question. I use Xeger (http://code.google.com/p/xeger/).

    First of all you need to download JAR from http://code.google.com/p/xeger/.

    Next you need to run in command line next command:

    mvn install:install-file -Dfile=~/Downloads/xeger-1.0-SNAPSHOT.jar -DgroupId=nl.flotsam -DartifactId=xeger -Dversion=1.0-SNAPSHOT -Dpackaging=jar

    There is linux-path to JAR file (~/Downloads/xeger-1.0-SNAPSHOT.jar). groupId, artifactId, version …. for xeger-1.0-SNAPSHOT.jar file. If you use another you need make some changes in command.

    Next you need to copy JAR file in to .m2/repository/nl/flotsam/xeger/1.0-SNAPSHOT dir

    in order to use Xeger you need also install in maven repository the dk.brics.automaton package.

    Here part of my pom.xml:

    <dependency>
        <groupid>nl.flotsam</groupid>
        <artifactid>xeger</artifactid>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupid>dk.brics</groupid>
        <artifactid>automaton</artifactid>
        <version>1.11</version>
    </dependency>

    If you have some questions you can create a comment for this post.

    Have a nice codding!