无法运行 leJOS NXJ 示例项目

发布于 2024-10-15 00:08:45 字数 7366 浏览 2 评论 0原文

我尝试在我的 MAC OS X 上安装 leJOS NXJ 并运行它是示例,但是在我做了它想要的事情并 导出 NXJ_Home 路径文件等之后。并安装 netbeans 插件并创建它的示例项目(使用Netbeans 插件)。我还遵循此结构并替换来自intsall的desireclasses.jar leJOS NXJ 安装的 lib 文件夹。

我导出这 4 行:

My-macbook-pro:~ AR$ export NXJ_HOME=/Users/AR/Documents/Research-kar/JAVA/lejos_nxj
My-macbook-pro:~ AR$ export DYLD_LIBRARY_PATH=$NXJ_HOME/bin
My-macbook-pro:~ AR$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
My-macbook-pro:~ AR$ export PATH=$PATH:$JAVA_HOME/bin:$NXJ_HOME/binamirrezas-macbook-pro:~ AR$ 

这是 leJOS NXJ 示例代码:

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();
    }
}

这是相关的 build.xml 文件:

<project name="Example" default="uploadandrun">
    <description>
        org.lejos.example.HelloWorld build file
    </description>

  <!-- set properties for this build -->
  <property environment = "env"/>
  <property file="build.properties"/>
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="program" value="Example"/>
  <property name="main.class" value="org.lejos.example.HelloWorld"/>
  <property name="binary" value="${build}/${program}.nxj" />

  <!-- deletes generated files -->
  <target name="clean" description="clean up all generated files">
    <delete dir="build"/>
  </target>

  <target name="compile" depends="clean"
        description="compile the source " >
    <!-- Compile the java code from ${src} to ${build}  -->
    <mkdir dir="${build}"/>
    <javac srcdir="${src}" destdir="${build}">
      <bootclasspath>
        <pathelement location="${nxj.classes.home}/lib/classes.jar"/>
      </bootclasspath>
    </javac>
  </target>

  <target name="link" depends="compile"
        description="link the binary " >
    <!-- Link the binary and create a signature file -->
    <java classname="js.tinyvm.TinyVM">
      <arg value="--bootclasspath"/>
      <arg path="${nxj.classes.jar}" />
      <arg value="--classpath"/>
      <arg path="${build}" />
      <arg value="--writeorder" />
      <arg value="LE" />
      <arg value="${main.class}"/>
      <arg value="-o"/>
      <arg value="${binary}"/>
      <arg value="-v"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="upload" depends="link"
        description="upload the binary" >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <jvmarg value="-Dnxj.home=${nxj.home}"/>
      <arg value="${binary}"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.pctools.jar}"/>
        <pathelement location="${nxj.pccomm.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
        <pathelement location="${nxj.bluecove.jar}"/>
        <pathelement location="${nxj.bluecove-gpl.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="uploadandrun" depends="link"
        description="upload and run the binary" >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <jvmarg value="-Dnxj.home=${nxj.home}"/>
      <arg value="${binary}"/>
      <arg value="-r"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.pctools.jar}"/>
        <pathelement location="${nxj.pccomm.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
        <pathelement location="${nxj.bluecove.jar}"/>
        <pathelement location="${nxj.bluecove-gpl.jar}"/>
      </classpath>
    </java>
  </target>

  <!--  used only for modifying the Netbeans NXJPlugin -->
    <target name="Zip for Netbeans" description="Zip the application to the sample project">
        <property name="build.classes.dir" location="/build"/>
        <property name="plugin" location="../NXJPlugin/src/nxjplugin/"/>
        <zip basedir="." destfile="${plugin}/NXJSampleProject.zip">
            <exclude name="**/build/"/>
            <exclude name="**/bin/"/>
            <exclude name="**/dist/"/>
            <exclude name="**/nbproject/private/"/>
        </zip>
    </target>
</project>

这是 ide-file-targets.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="org.lejos.example-IDE">
    <target name="run-selected-file-in-src">
        <fail unless="run.class">Must set property 'run.class'</fail>
        <ant antfile="build.xml" target="uploadandrun">
            <property name="main.class" value="${run.class}"/>
        </ant>
    </target>

    <target name="compile-selected-files-in-src">
        <ant antfile="build.xml" target="compile"/>
    </target>
</project>

我收到此错误:

run-selected-file-in-src:
    clean:
    Deleting directory /Users/AR/Documents/NetBeansProjects/NXJSample/build
    compile:
    Created dir: /Users/AR/Documents/NetBeansProjects/NXJSample/build
    Compiling 1 source file to /Users/AR/Documents/NetBeansProjects/NXJSample/build
    /Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:3: package lejos.nxt does not exist
    import lejos.nxt.*;
    /Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:13: cannot find symbol
    symbol  : variable Button
    location: class org.lejos.example.HelloWorld
                    Button.waitForPress();
                    ^
    2 errors
    /Users/AR/Documents/NetBeansProjects/NXJSample/nbproject/ide-file-targets.xml:5: The following error occurred while executing this line:
    /Users/AR/Documents/NetBeansProjects/NXJSample/build.xml:24: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 0 seconds)


  [1]: http://lejos.sourceforge.net/

I try to install leJOS NXJ on my MAC OS X and run it's sample, but after I do what it wants and export NXJ_Home Path file and etc. and install netbeans plugin and create it sample project (Creating your own project using the Netbeans Plugin). I also follow this structure and replace desire classes.jar from intsall leJOS NXJ installation's lib folder.

I export these 4 lines:

My-macbook-pro:~ AR$ export NXJ_HOME=/Users/AR/Documents/Research-kar/JAVA/lejos_nxj
My-macbook-pro:~ AR$ export DYLD_LIBRARY_PATH=$NXJ_HOME/bin
My-macbook-pro:~ AR$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
My-macbook-pro:~ AR$ export PATH=$PATH:$JAVA_HOME/bin:$NXJ_HOME/binamirrezas-macbook-pro:~ AR$ 

This is leJOS NXJ sample code:

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();
    }
}

and this is related build.xml file:

<project name="Example" default="uploadandrun">
    <description>
        org.lejos.example.HelloWorld build file
    </description>

  <!-- set properties for this build -->
  <property environment = "env"/>
  <property file="build.properties"/>
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="program" value="Example"/>
  <property name="main.class" value="org.lejos.example.HelloWorld"/>
  <property name="binary" value="${build}/${program}.nxj" />

  <!-- deletes generated files -->
  <target name="clean" description="clean up all generated files">
    <delete dir="build"/>
  </target>

  <target name="compile" depends="clean"
        description="compile the source " >
    <!-- Compile the java code from ${src} to ${build}  -->
    <mkdir dir="${build}"/>
    <javac srcdir="${src}" destdir="${build}">
      <bootclasspath>
        <pathelement location="${nxj.classes.home}/lib/classes.jar"/>
      </bootclasspath>
    </javac>
  </target>

  <target name="link" depends="compile"
        description="link the binary " >
    <!-- Link the binary and create a signature file -->
    <java classname="js.tinyvm.TinyVM">
      <arg value="--bootclasspath"/>
      <arg path="${nxj.classes.jar}" />
      <arg value="--classpath"/>
      <arg path="${build}" />
      <arg value="--writeorder" />
      <arg value="LE" />
      <arg value="${main.class}"/>
      <arg value="-o"/>
      <arg value="${binary}"/>
      <arg value="-v"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="upload" depends="link"
        description="upload the binary" >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <jvmarg value="-Dnxj.home=${nxj.home}"/>
      <arg value="${binary}"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.pctools.jar}"/>
        <pathelement location="${nxj.pccomm.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
        <pathelement location="${nxj.bluecove.jar}"/>
        <pathelement location="${nxj.bluecove-gpl.jar}"/>
      </classpath>
    </java>
  </target>

  <target name="uploadandrun" depends="link"
        description="upload and run the binary" >
    <java classname="lejos.pc.tools.NXJUpload" fork="true">
      <jvmarg value="-Djava.library.path=${nxj.library.path}"/>
      <jvmarg value="-Dnxj.home=${nxj.home}"/>
      <arg value="${binary}"/>
      <arg value="-r"/>
      <classpath>
        <pathelement location="${nxj.jtools.jar}"/>
        <pathelement location="${nxj.pctools.jar}"/>
        <pathelement location="${nxj.pccomm.jar}"/>
        <pathelement location="${nxj.commons.jar}"/>
        <pathelement location="${nxj.bcel.jar}"/>
        <pathelement location="${nxj.bluecove.jar}"/>
        <pathelement location="${nxj.bluecove-gpl.jar}"/>
      </classpath>
    </java>
  </target>

  <!--  used only for modifying the Netbeans NXJPlugin -->
    <target name="Zip for Netbeans" description="Zip the application to the sample project">
        <property name="build.classes.dir" location="/build"/>
        <property name="plugin" location="../NXJPlugin/src/nxjplugin/"/>
        <zip basedir="." destfile="${plugin}/NXJSampleProject.zip">
            <exclude name="**/build/"/>
            <exclude name="**/bin/"/>
            <exclude name="**/dist/"/>
            <exclude name="**/nbproject/private/"/>
        </zip>
    </target>
</project>

and this is ide-file-targets.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="org.lejos.example-IDE">
    <target name="run-selected-file-in-src">
        <fail unless="run.class">Must set property 'run.class'</fail>
        <ant antfile="build.xml" target="uploadandrun">
            <property name="main.class" value="${run.class}"/>
        </ant>
    </target>

    <target name="compile-selected-files-in-src">
        <ant antfile="build.xml" target="compile"/>
    </target>
</project>

I get this error:

run-selected-file-in-src:
    clean:
    Deleting directory /Users/AR/Documents/NetBeansProjects/NXJSample/build
    compile:
    Created dir: /Users/AR/Documents/NetBeansProjects/NXJSample/build
    Compiling 1 source file to /Users/AR/Documents/NetBeansProjects/NXJSample/build
    /Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:3: package lejos.nxt does not exist
    import lejos.nxt.*;
    /Users/AR/Documents/NetBeansProjects/NXJSample/src/org/lejos/example/HelloWorld.java:13: cannot find symbol
    symbol  : variable Button
    location: class org.lejos.example.HelloWorld
                    Button.waitForPress();
                    ^
    2 errors
    /Users/AR/Documents/NetBeansProjects/NXJSample/nbproject/ide-file-targets.xml:5: The following error occurred while executing this line:
    /Users/AR/Documents/NetBeansProjects/NXJSample/build.xml:24: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 0 seconds)


  [1]: http://lejos.sourceforge.net/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仄言 2024-10-22 00:08:45

有点晚了,但可能其他像我一样正在寻找解决方案。我是 leJOS、Netbeans 和 Java 的新手(从今晚开始)。

我的环境是WindowsXP和Netbeans 6.9.1。

leJOS 安装在 C:/Programme/leJOS NXJ

第一个项目:HelloWorld


我通过在 build.properties 文件中设置 nxj.home var 修复了它放在项目根目录下(这里/HelloWorld/和build.xml也在那里)。

nxj.home必须指向leJOS安装路径。就我而言:
nxj.home=C:/Programme/leJOS NXJ

希望它对

乔有帮助。

a little bit late but may other like me are looking for a solution. I am new on leJOS and Netbeans and Java (starting tonight).

My environment is WindowsXP with Netbeans 6.9.1.

leJOS is installed in C:/Programme/leJOS NXJ

First Project: HelloWorld


I fixed it by setting the nxj.home var in the build.properties file laying in the project root directory (here /HelloWorld/ and build.xml is also there).

The nxj.home has to point to the leJOS installation path. In my case:
nxj.home=C:/Programme/leJOS NXJ

Hope it helps

Joe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文