Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Installing LeJOS 0.6 for MindStorms on 8.04

  1. #1
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Beans
    4
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Lightbulb Installing LeJOS 0.6 for MindStorms on 8.04

    For the benefit of anyone running Hardy Heron who wants to use leJOS, I've summarized the steps (minus my errors and back-tracking!) to install and configure leJOS to work on my Ubuntu laptop with Bluetooth.

    I run Ubuntu 8.04 fully updated on a new HP Pavilion DV9744CA latop with a D-Link DBT-120 Bluetooth Dongle.
    • 1. Install these development packages:

      • sudo apt-get install libusb-dev
        sudo apt-get install libbluetooth-dev
        sudo apt-get install gcj


      2. Use Synaptic Package Manager to install NetBeans if you want to use NetBeans--I happen to prefer it but it's a personal choice

      3. NetBeans is installed with the openjdk Java Development Kit. The leJOS development team forum recommends using the Sun Java 1.6 SDK which can also be downloaded with Synaptic

      4. If you download the Sun Java 1.6 SDK, edit the NetBeans launcher to include --jdkhome /usr/lib/jvm/java-6-sun-1.6.0.06 so that it uses the Java Sun version and not the openjdk

      5. You will also have to choose which version you will use: sudo update-alternatives - - config java (I found that here http://forum.java.sun.com/thread.jsp...sageID=9756412 and here http://ubuntuforums.org/showthread.php?t=543965

      6. Visit http://lejos.sourceforge.net and download the lejos_NXT_0_6_0beta.tar.gz tarball (I saved it in /usr/bin/lejos)

      7. Unpack it: tar xfvz lejos_NXT_0_6_0beta.tar.gz.

      8. Move it to the spot you want it: sudo mv /usr/bin/lejos /user/share/lejos.

      9. Give everyone read and write privileges: chmod 777 /usr/share/lejos/bin --recursive.

      10. Edit your .profile file by adding these lines to the very end so that you can build the leJOS installation, and then reboot: sudo gedit ~.profile

      • export PATH=/usr/share/lejos/bin:$PATH
        export PATH=/usr.share/ant/bin:$PATH
        export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.06
        export NXT_HOME=/usr/share/lejos


      11. Move to the /usr/share/lejos/build folder and run ant to build your installation: ant

      12. At this point it works with USB but not Bluetooth. If you don't have root privileges, you can run run sudo -s to open a root window before using any of the nxt commands like nxjbrowse, nxjc or nxj.

      13. This is where you install the leJOS firmware. Connect it to your computer using the USB cable and make sure it's on. You will have to use a bent paperclip to depress the reset button in one of the grooves. When the device starts audibly clicking. Run nxjflash from a root window. There might be a data aborts—if it doesn't work, pop out a battery, put it back in and try again.

      14. Edit your .profile file to include the following and then reboot:
      sudo gedit ~/.profile

      • export PATH=/usr/share/lejos/lib:$PATH
        export PATH=/usr/share/lejos/3rdparty/lib:$PATH
        export CLASSPATH=/usr/share/lejos/lib/classes.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/lib/jtools.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/lib/pccomm.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/lib/pctools.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/bcel-5.1.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove203.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove-gpl.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/commons-cli-1.0.jar:$CLASSPATH
        export CLASSPATH=/usr/share/lejos/3rdparty/lib/cpptasks.jar:$CLASSPATH


      15. Copy libjlibnxt.so from the /usr/share/lejos/bin folder to the /usr/lib/jvm/java-6-openjdk/jre/lib/i386 folder

      16. Add Bluetooth Analyzer to the Applications/Accessories menu

      17. Create a file called /etc/udev/rules/70-lego.rules with this content (you can find the idVendor for the dongle by running lsusb):

      • BUS=="usb", SYSFS{idVendor}=="03eb", GROUP="lego", MODE="0660" /* Atmel */
        BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660" /* Lego */
        BUS=="usb", SYSFS{idVendor}=="0a12", GROUP="lego", MODE="0660" /* Dongle */


      18. Create a group called lego and add yourself to it in System/Administration/Users and Groups/Manage Groups

      19. Create file NXT.properties in /usr/share/lejos/bin, with NXTCommBluetooth=lejos.pc.comm.NXTCommBluecove as the only text

      20. Plug in the dongle. Ubuntu's Bluetooth Analyzer will open and an icon will appear in your panel

      21. Get the NXT's Bluetooth address with the hcitool scan command (it will look like this 00:16:53:05:CA:2C)

      22. You may need to delete the /var/lib/bluetooth/00:13:46:11:CD:01 directory (I found this in a forum posting and I tried doing this when I couldn't connect and it seemed to work): rm -rf 00:13:46:11:CD:01

      23. On the NXT brick turn on Bluetooth and enable visibility. Search for your computer and add the device

      24. Run nxjbrowse from a terminal and, when prompted by Bluetooth Analyzer, provide the default NXT password 1234 (this is called pairing and should only have to be done once). You should get a Java window popup prompting you to connect to your NXT brick. Make a note of the name and MAC address

      25. You may need to go into Bluetooth Manager/Preferences and change the Mode of Operation to “Visible and Connectable for other devices”. Also enable Receive Files from Remote Devices under File Transfer

      26. Reboot. Make sure the NXT brick is on and Bluetooth is enabled and the device is visible. Run nxjbrowse. You should successfully connect.

      27. Move to the samples folder and compile BTReceive (nxjc BTReceive.java). Compile BTSend (this one is compiled with javac as specified in the file comments). Ensure that the NXT brick is on and Bluetooth is on and the device is visible. Upload the BTReceive file to the NXT (nxj BTReceive). If there is a data abort (which seems to occur from time to occasional time with this beta) you will have to remove a battery and restart the NXT and try to upload it again.

      28.From your root window, run java BTSend [NXT_NAME] [NXT-Address]. You should see a stream of integers being exchanged between your computer and the brick. Tada!
    Last edited by VancouverCowboy; July 13th, 2008 at 04:54 AM. Reason: Correct typos.

  2. #2
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Smile Re: Installing LeJOS 0.6 for MindStorms on 8.04

    Thanks a lot I had it working at one point then had to reinstall. I completely forgot what I did before. This helped a lot Thank you!!

  3. #3
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Lightbulb Re: Installing LeJOS 0.6 for MindStorms on 8.04

    However there is an easier way to edit environment variables. Go to a terminal and type
    Code:
    cd /etc
    and
    Code:
     sudo gedit environment
    . However, beware of one thing. Since the PATH variable is already defined, you should append the PATH modifications to the end of the line, just before the quotes. And another thing, you don't need the
    Code:
    export
    command before every line when you edit the environment file. Other than that, your method worked perfectly. By the way, you don't need to create udev rules or even do all that classpath stuff. Simply 'cd'ing to the directory with the java files and 'nxjc'ing it should do the trick.
    Last edited by chaanakya_chiraag; August 8th, 2008 at 05:24 PM.

  4. #4
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Exclamation Re: Installing LeJOS 0.6 for MindStorms on 8.04

    By the way, anybody having trouble using USB with the NXT should try
    Code:
    sudo -s
    export NXJ_HOME=(path to lejos home directory)
    export JAVA_HOME=(path to java home directory)
    export PATH=$PATH:(path to lejos home directory)/bin:(path to java home directory)/bin
    cd (path to lejos executables)
    and execute whichever one you need. However, this may not be the most convenient way. In order to make the changes stick, you have to edit a file called bash.bashrc in /etc. Then, add the previous environment variables and you should be good to go.

  5. #5
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Beans
    4
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Installing LeJOS 0.6 for MindStorms on 8.04

    Thanks that's great!

  6. #6
    Join Date
    Aug 2008
    Location
    Guatemala
    Beans
    6
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Installing LeJOS 0.6 for MindStorms on 8.04

    How exactly do you edit the bash.bashrc file in /etc?

    I mean, I have set up the PATH with the /bin from lejos, but I haven't been able to set up the NXJ_HOME variable.

    By the way, I'm loving this thread... for real, loving it ^^
    Last edited by herrBua; September 7th, 2008 at 02:45 AM.

  7. #7
    Join Date
    Aug 2008
    Location
    Guatemala
    Beans
    6
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Installing LeJOS 0.6 for MindStorms on 8.04

    I seem to be unable to compile the BTSend.java file. The compiler tells me that the error ocurrs when trying to import the "lejos.pc.comm" package.

    There are a couple of parts of the whole list I didn't exactly do. For example, editing my .profile. Instead i edited the bash.bashrc adding the NXJ_HOME, JAVA_HOME and PATH lines.

    14. Edit your .profile file to include the following and then reboot:
    sudo gedit ~/.profile

    * export PATH=/usr/share/lejos/lib:$PATH
    export PATH=/usr/share/lejos/3rdparty/lib:$PATH
    export CLASSPATH=/usr/share/lejos/lib/classes.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/lib/jtools.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/lib/pccomm.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/lib/pctools.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/bcel-5.1.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove203.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove-gpl.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/commons-cli-1.0.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos/3rdparty/lib/cpptasks.jar:$CLASSPATH
    This part I also added to the bash.bashrc file, but I believe I did something wrong, because the CLASSPATH should have already been modified but the Java compiler tells me otherwise.

    Inside of the BTSend.java file there's a line that says:
    "On Linux, you will need libjbluez.so on the Java library path."

    That's another thing I don't know how to do, edit the Java library path.

    If you guys could help me out with this I'd really appreciate it. I'm almost done setting up lejos in Ubuntu and I'd really like to finish this.

    By the way, my bash.bashrc looks like this:

    # System-wide .bashrc file for interactive bash(1) shells.

    # To enable the settings / commands in this file for login shells as well,
    # this file has to be sourced in /etc/profile.

    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi

    # set a fancy prompt (non-color, overwrite the one in /etc/profile)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

    # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
    # If this is an xterm set the title to user@host:dir
    #case "$TERM" in
    #xterm*|rxvt*)
    # PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    # ;;
    #*)
    # ;;
    #esac

    # enable bash completion in interactive shells
    #if [ -f /etc/bash_completion ]; then
    # . /etc/bash_completion
    #fi

    # sudo hint
    if [ ! -e $HOME/.sudo_as_admin_successful ]; then
    case " $(groups) " in *\ admin\ *)
    if [ -x /usr/bin/sudo ]; then
    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.

    EOF
    fi
    esac
    fi

    # if the command-not-found package is installed, use it
    if [ -x /usr/lib/command-not-found ]; then
    function command_not_found_handle {
    # check because c-n-f could've been removed in the meantime
    if [ -x /usr/lib/command-not-found ]; then
    /usr/bin/python /usr/lib/command-not-found -- $1
    return $?
    else
    return 127
    fi
    }
    fi

    NXJ_HOME=/home/kurt/lejos_nxj
    JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.06
    PATH=$PATH:/home/kurt/lejos_nxj/bin:/usr/lib/jvm/java-6-sun-1.6.0.06/bin

    PATH=$PATH:/home/kurt/lejos_nxj/lib
    PATH=$PATH:/home/kurt/lejos_nxj/lib
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/lib/classes.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/lib/jtools.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/lib/pccomm.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/lib/pctools.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/bcel-5.1.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/bluecove.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/bluecove203.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/bluecove-gpl.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/commons-cli-1.0.jar
    CLASSPATH=$CLASSPATH:/home/kurt/lejos_nxj/3rdparty/lib/cpptasks.jar
    I'm sorry that my post is this big, but I wanted to write as detailed as possible.

    Thank you in advance.

  8. #8
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Beans
    4
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Installing LeJOS 0.6 for MindStorms on 8.04

    All I can suggest is you start over at the top of the list and do everything in it. If you skip some steps, then I can't guarantee it'll work. Make sure you've done every single step and then tell us what your systems does...

  9. #9
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Wink Re: Installing LeJOS 0.6 for MindStorms on 8.04

    To load the libjbluez.so module, copy the libjbluez.so(.bak?) to /lib and set correct permissions. Then in BTSend, add the following line right before the lejos.pccomm line:
    Code:
    Runtime.getRuntime().load("/lib/libjbluez.so");
    That should fix that problem. I had to do a LOT of research before I stumbled upon this one.
    Wait, there's an asterisk next to the first export. Try removing that and see if that fixes things. If it doesn't, try running the following code in Terminal:
    Code:
    echo $CLASSPATH
    If this returns an empty line, your classpath is not being set at all. If it displays what you have posted, then I have no clue why the Java compiler is not recognizing the classpath and I can't help you further.

    By the way, here's my bash.bashrc:

    Code:
    # System-wide .bashrc file for interactive bash(1) shells.
    
    # To enable the settings / commands in this file for login shells as well,
    # this file has to be sourced in /etc/profile.
    
    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, overwrite the one in /etc/profile)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    
    # Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
    # If this is an xterm set the title to user@host:dir
    #case "$TERM" in
    #xterm*|rxvt*)
    #    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
    #    ;;
    #*)
    #    ;;
    #esac
    
    # enable bash completion in interactive shells
    #if [ -f /etc/bash_completion ]; then
    #    . /etc/bash_completion
    #fi
    
    # sudo hint
    if [ ! -e $HOME/.sudo_as_admin_successful ]; then
        case " $(groups) " in *\ admin\ *)
        if [ -x /usr/bin/sudo ]; then
    	cat <<-EOF
    	To run a command as administrator (user "root"), use "sudo <command>".
    	See "man sudo_root" for details.
    	
    	EOF
        fi
        esac
    fi
    
    # if the command-not-found package is installed, use it
    if [ -x /usr/lib/command-not-found ]; then
    	function command_not_found_handle {
    	        # check because c-n-f could've been removed in the meantime
                    if [ -x /usr/lib/command-not-found ]; then
    		   /usr/bin/python /usr/lib/command-not-found -- $1
                       return $?
    		else
    		   return 127
    		fi
    	}
    fi
    
    export NXJ_HOME=/usr/share/lejos_nxj
    export JAVA_HOME=/home/chiraag/jdk1.6.0_10
    export PATH=$PATH:/usr/share/lejos_nxj/bin:/home/chiraag/jdk1.6.0_10/bin
    export PATH=/usr/share/lejos_nxj/lib:$PATH
    export PATH=/usr/share/lejos_nxj/3rdparty/lib:$PATH
    export CLASSPATH=.:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/lib/classes.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/lib/jtools.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/lib/pccomm.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/lib/pctools.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/bcel-5.1.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/bluecove.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/bluecove203.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/bluecove-gpl.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/commons-cli-1.0.jar:$CLASSPATH
    export CLASSPATH=/usr/share/lejos_nxj/3rdparty/lib/cpptasks.jar:$CLASSPATH
    Last edited by chaanakya_chiraag; October 26th, 2008 at 07:22 PM. Reason: Make it clearer

  10. #10
    Join Date
    May 2008
    Beans
    605
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Installing LeJOS 0.6 for MindStorms on 8.04

    Darn it! I just upgraded to intrepid and when i try to connect to the nxt, it says connecting and hangs there. Anybody know what to do?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •