http://sourceforge.net/projects/lejos/files/lejos-NXJ-win32/0.9.0beta/
웹에 보면, lejos_NXJ_win32_0_9_0beta.zip  파일이 존재하는데. 이 녀석에 예제가 포함되어 있다.

압축을 풀고 나서, eclipse 에서 import 하면 간단한 테스트가 가능하다.
D:\LEGO\lejos\lejos_NXJ_win32_0_9_0beta\lejos_nxj\projects\org.lejos.example


Hello World 을 간단하게 출력하는 예제이다.

package org.lejos.example;
import lejos.nxt.*;
/**
 * Example leJOS Project with an ant build file
 *
 */
public class HelloWorld {
 public static void main(String[] args) {
  System.out.println("Hello World");
  Button.waitForPress();
 }
}



NXT의 전원을 켜고, ant build만 하면 오케이다.


ant 빌드 결과물이이다. build 결과물은 다음과 같다.


Buildfile: D:\LEGO\lejos\lejos_NXJ_win32_0_9_0beta\lejos_nxj\projects\org.lejos.example\build.xml
clean:
      [delete] Deleting directory D:\LEGO\lejos\lejos_NXJ_win32_0_9_0beta\lejos_nxj\projects\org.lejos.example\build
compile:
       [mkdir] Created dir: D:\LEGO\lejos\lejos_NXJ_win32_0_9_0beta\lejos_nxj\projects\org.lejos.example\build
       [javac] Compiling 1 source file to D:\LEGO\lejos\lejos_NXJ_win32_0_9_0beta\lejos_nxj\projects\org.lejos.example\build
link:
        [java] Class 0: java.lang.Object
        [java] Class 1: java.lang.Throwable
        [java] Class 2: java.lang.Error
        [java] Class 3: java.lang.OutOfMemoryError
        [java] Class 4: boolean
        [java] Class 5: char
        [java] Class 6: float
        [java] Class 7: double
        [java] Class 8: byte
        [java] Class 9: short
        [java] Class 10: int
        [java] Class 11: long
        [java] Class 12: void
        [java] Class 13: java.lang.Object[]
        [java] Class 14: java.lang.NoSuchMethodError
        [java] Class 15: java.lang.StackOverflowError
        [java] Class 16: java.lang.NullPointerException
        [java] Class 17: boolean[]
        [java] Class 18: char[]
        [java] Class 19: float[]
        [java] Class 20: double[]
        [java] Class 21: byte[]
        [java] Class 22: short[]
        [java] Class 23: int[]
        [java] Class 24: long[]
        [java] Class 25: reserved
        [java] Class 26: java.lang.ClassCastException
        [java] Class 27: java.lang.ArithmeticException
        [java] Class 28: java.lang.ArrayIndexOutOfBoundsException
        [java] Class 29: java.lang.IllegalArgumentException
        [java] Class 30: java.lang.InterruptedException
        [java] Class 31: java.lang.IllegalStateException
        [java] Class 32: java.lang.IllegalMonitorStateException
        [java] Class 33: java.lang.ThreadDeath
        [java] Class 34: java.lang.ArrayStoreException
        [java] Class 35: java.lang.NegativeArraySizeException
        [java] Class 36: java.lang.Class
        [java] Class 37: java.lang.String
        [java] Class 38: java.lang.Cloneable
        [java] Class 39: java.lang.Thread
        [java] Class 40: org.lejos.example.HelloWorld
        [java] Class 41: lejos.nxt.VM
        [java] Class 42: java.lang.System
        [java] Class 43: java.lang.StringBuilder
        [java] Class 44: java.lang.Integer
        [java] Class 45: java.io.PrintStream
        [java] Class 46: java.lang.RuntimeException
        [java] Class 47: java.lang.Exception
        [java] Class 48: java.lang.IndexOutOfBoundsException
        [java] Class 49: java.lang.Character
        [java] Class 50: java.lang.StringIndexOutOfBoundsException
        [java] Class 51: java.lang.StringUtils
        [java] Class 52: java.lang.Runnable
        [java] Class 53: lejos.nxt.Button
        [java] Class 54: lejos.nxt.VM.VMImage
        [java] Class 55: lejos.nxt.VM.VMClone
        [java] Class 56: lejos.nxt.LCDOutputStream
        [java] Class 57: java.lang.Number
        [java] Class 58: java.lang.NumberFormatException
        [java] Class 59: java.io.OutputStream
        [java] Class 60: java.io.IOException
        [java] Class 61: lejos.nxt.NXTEvent
        [java] Class 62: lejos.nxt.Sound
        [java] Class 63: lejos.nxt.SystemSettings
        [java] Class 64: lejos.nxt.Button[]
        [java] Class 65: lejos.nxt.LCD
        [java] Class 66: lejos.nxt.Flash
        [java] Class 67: java.lang.String[]
        [java] Class 68: lejos.nxt.FlashError
        [java] Class 69: lejos.nxt.NXT
        [java] Method 0: java.lang.Object.<init>() PC 3256 Signature id 2
        [java] Method 1: java.lang.Object.getClass() PC 3257 Signature id 121
        [java] Method 2: java.lang.Object.toString() PC 3265 Signature id 123
        [java] Method 3: java.lang.Object.wait(long) Native id 7
        [java] Method 4: java.lang.Throwable.<init>() PC 3293 Signature id 2
        [java] Method 5: java.lang.Throwable.<init>(java.lang.String) PC 3303 Signature id 124
        [java] Method 6: java.lang.Throwable.getLocalizedMessage() PC 3318 Signature id 125
        [java] Method 7: java.lang.Throwable.getMessage() PC 3323 Signature id 29
        [java] Method 8: java.lang.Throwable.toString() PC 3328 Signature id 123
        [java] Method 9: java.lang.Throwable.fillInStackTrace() PC 3376 Signature id 126
        [java] Method 10: java.lang.Error.<init>(java.lang.String) PC 3389 Signature id 124
        [java] Method 11: java.lang.NullPointerException.<init>() PC 3395 Signature id 2
        [java] Method 12: java.lang.IllegalArgumentException.<init>(java.lang.String) PC 3400 Signature id 124
        [java] Method 13: java.lang.Class.isInterface() PC 3406 Signature id 133
        [java] Method 14: java.lang.Class.toString() PC 3423 Signature id 123
        [java] Method 15: java.lang.String.<init>(int) PC 3469 Signature id 128
        [java] Method 16: java.lang.String.<init>(char[]) PC 3481 Signature id 140
        [java] Method 17: java.lang.String.<init>(char[], int, int) PC 3490 Signature id 141
        [java] Method 18: java.lang.String.charAt(int) PC 3507 Signature id 145
        [java] Method 19: java.lang.String.equals(java.lang.Object) PC 3532 Signature id 120
        [java] Method 20: java.lang.String.length() PC 3604 Signature id 155
        [java] Method 21: java.lang.String.toString() PC 3610 Signature id 123
        [java] Method 22: java.lang.String.valueOf(java.lang.Object) PC 3612 Signature id 167
        [java] Method 23: java.lang.Thread.run() PC 3626 Signature id 1
        [java] Method 24: java.lang.Thread.currentThread() Native id 12
        [java] Method 25: java.lang.Thread.interrupt() Native id 15
        [java] Method 26: org.lejos.example.HelloWorld.main(java.lang.String[]) PC 3646 Signature id 0
        [java] Method 27: lejos.nxt.VM.<clinit> PC 3659 Signature id 3
        [java] Method 28: lejos.nxt.VM.<init>() PC 3678 Signature id 2
        [java] Method 29: lejos.nxt.VM.getVM() PC 3713 Signature id 175
        [java] Method 30: lejos.nxt.VM.memPeek(int, int, int) Native id 103
        [java] Method 31: lejos.nxt.VM.memCopy(java.lang.Object, int, int, int, int) Native id 104
        [java] Method 32: lejos.nxt.VM.getObjectAddress(java.lang.Object) Native id 105
        [java] Method 33: lejos.nxt.VM.memGetReference(int, int) Native id 106
        [java] Method 34: lejos.nxt.VM.memPeekByte(int, int) PC 3733 Signature id 176
        [java] Method 35: lejos.nxt.VM.memPeekShort(int, int) PC 3745 Signature id 177
        [java] Method 36: lejos.nxt.VM.memPeekInt(int, int) PC 3756 Signature id 178
        [java] Method 37: lejos.nxt.VM.getClassAddress(int) PC 3764 Signature id 179
        [java] Method 38: lejos.nxt.VM.getClassNo(java.lang.Object) PC 3780 Signature id 180
        [java] Method 39: lejos.nxt.VM.getClassNumber(java.lang.Class) PC 3807 Signature id 181
        [java] Method 40: lejos.nxt.VM.getClass(java.lang.Object) PC 3824 Signature id 183
        [java] Method 41: lejos.nxt.VM.createStackTrace(java.lang.Thread, java.lang.Object) Native id 114
        [java] Method 42: lejos.nxt.VM.access$100(java.lang.Object, int, int, int, int) PC 3840 Signature id 188
        [java] Method 43: java.lang.System.<clinit> PC 3850 Signature id 3
        [java] Method 44: java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int) Native id 24
        [java] Method 45: java.lang.System.currentTimeMillis() Native id 22
        [java] Method 46: java.lang.System.identityHashCode(java.lang.Object) PC 3885 Signature id 200
        [java] Method 47: java.lang.System.getDataAddress(java.lang.Object) Native id 8
        [java] Method 48: java.lang.StringBuilder.ensureCapacity(int) PC 3890 Signature id 201
        [java] Method 49: java.lang.StringBuilder.<init>() PC 3949 Signature id 2
        [java] Method 50: java.lang.StringBuilder.append(java.lang.String) PC 3967 Signature id 202
        [java] Method 51: java.lang.StringBuilder.append(int) PC 3973 Signature id 206
        [java] Method 52: java.lang.StringBuilder.appendInternal(java.lang.String) PC 4011 Signature id 207
        [java] Method 53: java.lang.StringBuilder.toString() PC 4062 Signature id 123
        [java] Method 54: java.lang.Integer.<clinit> PC 4079 Signature id 3
        [java] Method 55: java.lang.Integer.parseInt(java.lang.String) PC 4084 Signature id 212
        [java] Method 56: java.lang.Integer.parseInt(java.lang.String, int) PC 4091 Signature id 213
        [java] Method 57: java.lang.Integer.parseInt(java.lang.String, int, int, boolean, int) PC 4138 Signature id 214
        [java] Method 58: java.lang.Integer.toHexString(int) PC 4263 Signature id 216
        [java] Method 59: java.lang.Integer.toUnsignedString(int, int, int, int) PC 4273 Signature id 217
        [java] Method 60: java.io.PrintStream.<init>(java.io.OutputStream) PC 4321 Signature id 222
        [java] Method 61: java.io.PrintStream.write(int) PC 4331 Signature id 223
        [java] Method 62: java.io.PrintStream.flush() PC 4358 Signature id 224
        [java] Method 63: java.io.PrintStream.print0(java.lang.String) PC 4370 Signature id 225
        [java] Method 64: java.io.PrintStream.println0(java.lang.String) PC 4396 Signature id 226
        [java] Method 65: java.io.PrintStream.println(java.lang.String) PC 4412 Signature id 227
        [java] Method 66: java.lang.RuntimeException.<init>() PC 4421 Signature id 2
        [java] Method 67: java.lang.RuntimeException.<init>(java.lang.String) PC 4426 Signature id 124
        [java] Method 68: java.lang.Exception.<init>() PC 4432 Signature id 2
        [java] Method 69: java.lang.Exception.<init>(java.lang.String) PC 4437 Signature id 124
        [java] Method 70: java.lang.IndexOutOfBoundsException.<init>(java.lang.String) PC 4443 Signature id 124
        [java] Method 71: java.lang.Character.<clinit> PC 4449 Signature id 3
        [java] Method 72: java.lang.Character.digit(int, int) PC 4454 Signature id 221
        [java] Method 73: java.lang.Character.forDigit(int, int) PC 4532 Signature id 240
        [java] Method 74: java.lang.StringIndexOutOfBoundsException.<init>(int) PC 4579 Signature id 128
        [java] Method 75: java.lang.StringUtils.parseDigit(char, int) PC 4603 Signature id 245
        [java] Method 76: java.lang.StringUtils.throwNumberFormat(java.lang.String, int) PC 4625 Signature id 246
        [java] Method 77: java.lang.StringUtils.getIntChars(char[], int, int, int) PC 4661 Signature id 248
        [java] Method 78: java.lang.StringUtils.exactStringLength(int, int) PC 4713 Signature id 250
        [java] Method 79: lejos.nxt.Button.<clinit> PC 4736 Signature id 3
        [java] Method 80: lejos.nxt.Button.<init>(int) PC 4827 Signature id 128
        [java] Method 81: lejos.nxt.Button.waitAllReleased(lejos.nxt.NXTEvent, long) PC 4837 Signature id 262
        [java] Method 82: lejos.nxt.Button.waitForPress(int) PC 4869 Signature id 263
        [java] Method 83: lejos.nxt.Button.waitForPress() PC 4942 Signature id 264
        [java] Method 84: lejos.nxt.Button.getButtons() Native id 47
        [java] Method 85: lejos.nxt.Button.readButtons() PC 4947 Signature id 265
        [java] Method 86: lejos.nxt.Button.loadSettings() PC 4991 Signature id 267
        [java] Method 87: lejos.nxt.VM.VMImage.<init>(lejos.nxt.VM, int) PC 5065 Signature id 268
        [java] Method 88: lejos.nxt.VM.VMImage.<init>(lejos.nxt.VM, int, lejos.nxt.VM$1) PC 5079 Signature id 269
        [java] Method 89: lejos.nxt.VM.VMClone.update() PC 5086 Signature id 290
        [java] Method 90: lejos.nxt.VM.VMClone.<init>(int, int) PC 5102 Signature id 284
        [java] Method 91: lejos.nxt.VM.VMClone.<init>(int, int, lejos.nxt.VM$1) PC 5121 Signature id 286
        [java] Method 92: lejos.nxt.LCDOutputStream.<init>() PC 5128 Signature id 2
        [java] Method 93: lejos.nxt.LCDOutputStream.write(int) PC 5138 Signature id 223
        [java] Method 94: java.lang.NumberFormatException.<init>(java.lang.String) PC 5193 Signature id 124
        [java] Method 95: java.io.OutputStream.<init>() PC 5199 Signature id 2
        [java] Method 96: java.io.OutputStream.write(int) PC 0 Signature id 223
        [java] Method 97: java.io.OutputStream.flush() PC 5204 Signature id 224
        [java] Method 98: lejos.nxt.NXTEvent.<init>() PC 5205 Signature id 2
        [java] Method 99: lejos.nxt.NXTEvent.registerEvent() Native id 117
        [java] Method 100: lejos.nxt.NXTEvent.unregisterEvent() Native id 118
        [java] Method 101: lejos.nxt.NXTEvent.changeEvent(int, int) Native id 119
        [java] Method 102: lejos.nxt.NXTEvent.waitEvent(long) PC 5210 Signature id 311
        [java] Method 103: lejos.nxt.NXTEvent.waitEvent(int, long) PC 5411 Signature id 312
        [java] Method 104: lejos.nxt.NXTEvent.allocate(int, int, int) PC 5422 Signature id 317
        [java] Method 105: lejos.nxt.NXTEvent.free() PC 5472 Signature id 318
        [java] Method 106: lejos.nxt.Sound.<clinit> PC 5498 Signature id 3
        [java] Method 107: lejos.nxt.Sound.playFreq(int, int, int) Native id 55
        [java] Method 108: lejos.nxt.Sound.playTone(int, int, int) PC 5607 Signature id 325
        [java] Method 109: lejos.nxt.Sound.loadSettings() PC 5633 Signature id 267
        [java] Method 110: lejos.nxt.SystemSettings.<clinit> PC 5644 Signature id 3
        [java] Method 111: lejos.nxt.SystemSettings.getSlot(java.lang.String) PC 5756 Signature id 330
        [java] Method 112: lejos.nxt.SystemSettings.setSlot(int, java.lang.String) PC 5788 Signature id 331
        [java] Method 113: lejos.nxt.SystemSettings.getValue(int) PC 5864 Signature id 332
        [java] Method 114: lejos.nxt.SystemSettings.getStringSetting(java.lang.String, java.lang.String) PC 5936 Signature id 333
        [java] Method 115: lejos.nxt.SystemSettings.getIntSetting(java.lang.String, int) PC 5963 Signature id 334
        [java] Method 116: lejos.nxt.SystemSettings.setSetting(java.lang.String, java.lang.String) PC 5983 Signature id 335
        [java] Method 117: lejos.nxt.LCD.<clinit> PC 6015 Signature id 3
        [java] Method 118: lejos.nxt.LCD.bitBlt(byte[], int, int, int, int, int, int, int, int, int) PC 6032 Signature id 366
        [java] Method 119: lejos.nxt.LCD.drawChar(char, int, int) PC 6059 Signature id 367
        [java] Method 120: lejos.nxt.LCD.getDisplay() Native id 42
        [java] Method 121: lejos.nxt.LCD.getSystemFont() Native id 45
        [java] Method 122: lejos.nxt.LCD.bitBlt(byte[], int, int, int, int, byte[], int, int, int, int, int, int, int) Native id 44
        [java] Method 123: lejos.nxt.LCD.scroll() PC 6088 Signature id 369
        [java] Method 124: lejos.nxt.Flash.<clinit> PC 6128 Signature id 3
        [java] Method 125: lejos.nxt.Flash.flashReadPage(byte[], int) Native id 71
        [java] Method 126: lejos.nxt.Flash.flashWritePage(byte[], int) Native id 70
        [java] Method 127: lejos.nxt.Flash.readPage(byte[], int) PC 6141 Signature id 407
        [java] Method 128: lejos.nxt.Flash.writePage(byte[], int) PC 6160 Signature id 408
        [java] Method 129: lejos.nxt.FlashError.<init>(java.lang.String) PC 6247 Signature id 124
        [java] Method 130: lejos.nxt.NXT.getUserPages() Native id 94
        [java] Master record    : 20 bytes.
        [java] Class records    : 70 (840 bytes).
        [java] Field records    : 56 (56 bytes).
        [java] Static fields    : 29 (60 bytes).
        [java] Static state     : 29 (112 bytes).
        [java] Constant records : 36 (144 bytes).
        [java] Constant values  : 36 (476 bytes).
        [java] Method records   : 131 (1572 bytes).
        [java] Exception records: 10 (80 bytes).
        [java] Interface maps   : 2 (4 bytes).
        [java] Code             : 108 (3000 bytes).
        [java] Total            : 6256 bytes.
        [java] Run time options : EnableCompact
        [java] Constant loads   : 36N 10O 1W 35S
        [java] Static load/store: 3N 70O
        [java] Field  load/store: 1N 80O
uploadandrun:
        [java] Found NXT: NXT 0016530EA6F8
        [java] leJOS NXJ> Connected to NXT
        [java] leJOS NXJ> Upload successful in 922 milliseconds
BUILD SUCCESSFUL
Total time: 3 seconds



build.xml 파일을 보면,
jvm 에서 실행할 수 있도록 기본 java binary 클래스들과 HelloWorld.class를 묶어 만든 HelloWorld.nxd 파일을  NXT로 다운로드 하는 구조로 되어 있는 것 같다. Littel Endian 설정도 눈에 보인다.  나중에 시간되는 대로 소스를 함 봐야겠다.

컴파일 -> lejos.pc.tools.NXJLink ->  lejos.pc.tools.NXJUpload 


NXT 결과물을 본다. Hello World 가 제대로 출력되었는지 확인가능하다.




내일은 몽땅 다 읽어봐야지.
http://www.docstoc.com/docs/2133860/The-leJOS-NXJ-Tutorial

Posted by 김용환 '김용환'

댓글을 달아 주세요

  1. 행인1 2012.04.02 21:47  댓글주소  수정/삭제  댓글쓰기

    블로그 잘봤습니다.
    제가 이번에 마인드스톰을 자바로 하려고 하는데요
    코딩하고 컴파일 하려고 하는데
    lejos.pc.tools.NXJLink를 찾을수가 없다고 뜨는 군요
    그래서 jar파일 뒤져보니까 NXJLink는 없고 NXJLinkAndUpload클래스만 있더군요
    어떻게 방법이 없을까요???