Project creation problem in NetBeans

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Project creation problem in NetBeans

Postby KittenFace » Sat Jan 01, 2011 4:28 pm

Hello,

I have just installed Lejos for netbeans with all the plugins and that sort of thing, and the sample projects load onto the nxt and run fine.

however when i try to run a new program (using this tutorial http://lejos.sourceforge.net/nxt/nxj/tu ... tbeans.htm) i get the following errors:

- warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
- Class org.lejos.example.HelloWorld (file org/lejos/example/HelloWorld.class) not found in CLASSPATH C:\Program Files (x86)\leJOS NXJ\lib\classes.jar;C:\Users\Fiona\Documents\NetBeansProjects\RoboProggAssessment1\build
js.tinyvm.TinyVMException: Class org.lejos.example.HelloWorld (file org/lejos/example/HelloWorld.class) not found in CLASSPATH C:\Program Files (x86)\leJOS NXJ\lib\classes.jar;C:\Users\Fiona\Documents\NetBeansProjects\RoboProggAssessment1\build
- a beep, and a notice of a java exception is printed to the nxt screen

i am unsure what is causing these problems, and have googled furiously but the problems still persist!

thanks for any help!
KittenFace
New User
 
Posts: 3
Joined: Sat Jan 01, 2011 4:16 pm

Re: Project creation problem in NetBeans

Postby Shawn » Sun Jan 02, 2011 8:37 am

KittenFace wrote:Hello,
- Class org.lejos.example.HelloWorld (file org/lejos/example/HelloWorld.class) not found in CLASSPATH C:\Program Files (x86)\leJOS NXJ\lib\classes.jar;C:\Users\Fiona\Documents\NetBeansProjects\RoboProggAssessment1\build
js.tinyvm.TinyVMException: Class org.lejos.example.HelloWorld (file org/lejos/example/HelloWorld.class) not found in CLASSPATH C:\Program Files (x86)\leJOS NXJ\lib\classes.jar;C:\Users\Fiona\Documents\NetBeansProjects\RoboProggAssessment1\build
- a beep, and a notice of a java exception is printed to the nxt screen


Hi,

I don't use netbeans but it looks like the common problem of setting it up to find your package.

I googled but didn't find an answer. I think the plugin is supposed to work with non default packages but perhaps it does not.

Anyway, for sure org/lejos/example/HelloWorld.class is not found, so either it is not being compiled, or as I mentioned the package is confusing to the plugin.

I'd take out your package declaration and move HelloWorld.java to the appropriate dir, then try again.

Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby KittenFace » Sun Jan 02, 2011 3:25 pm

riiight, the class not found error has been solved and the program is loaded and executable on the nxt even with the remaining presence of the 'ncludeantruntime' error.

what strikes me as odd with the current working, is that there are no compiler errors or anything, despite netbeans claiming that package lejos.ntx doesnt exist!
KittenFace
New User
 
Posts: 3
Joined: Sat Jan 01, 2011 4:16 pm

Re: Project creation problem in NetBeans

Postby codexJava » Thu Aug 04, 2011 4:10 am

Hi,

I seem to be having a problem in NetBeans when trying to upload and run my project Test2. Basically, I am able to compile and clean my case, but when I try to upload and run, I get the following output error message:

Code: Select all
[parsing started /Users/anthonyreed/lejos_nxj/projects/Test2/src/Main.java]
[parsing completed 1ms]
[search path for source files: /Users/anthonyreed/lejos_nxj/projects/Test2/src]
[search path for class files: /Users/anthonyreed/lejos_nxj/lib/nxt/classes.jar,/Users/anthonyreed/lejos_nxj/projects/Test2/build,/Users/anthonyreed/lejos_nxj/projects/Test2/build]
[loading java/lang/Object.class(java/lang:Object.class)]
[loading java/lang/String.class(java/lang:String.class)]
[checking org.lejos.example.Main]
[loading java/lang/System.class(java/lang:System.class)]
[loading java/io/PrintStream.class(java/io:PrintStream.class)]
[loading java/io/OutputStream.class(java/io:OutputStream.class)]
[loading lejos/nxt/Button.class(lejos/nxt:Button.class)]
[wrote /Users/anthonyreed/lejos_nxj/projects/Test2/build/org/lejos/example/Main.class]
[total 15ms]
link:
js.tinyvm.TinyVMException: Class ${package}.${main.class} (file ${package}/${main/class}.class) not found in CLASSPATH /Users/anthonyreed/lejos_nxj/lib/nxt/classes.jar:/Users/anthonyreed/lejos_nxj/projects/Test2/build
   at js.tinyvm.ClassRecord.getClassRecord(ClassRecord.java:855)
   at js.tinyvm.Binary.processClasses(Binary.java:365)
   at js.tinyvm.Binary.createFromClosureOf(Binary.java:312)
   at js.tinyvm.TinyVMTool.link(TinyVMTool.java:98)
   at js.tinyvm.TinyVMTool.link(TinyVMTool.java:49)
   at lejos.pc.tools.NXJLink.start(NXJLink.java:134)
   at lejos.pc.tools.NXJLink.run(NXJLink.java:101)
   at lejos.pc.tools.NXJLink.start(NXJLink.java:33)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at lejos.pc.tools.ToolStarter.startTool(ToolStarter.java:31)
   at lejos.pc.tools.NXJLink.main(NXJLink.java:28)
/Users/anthonyreed/lejos_nxj/projects/Test2/build.xml:54: Java returned: 1


I believe the problem lies within my build.xml file, but I am relatively new to Java and ant for that matter to know what's going on. Does anyone have any ideas on how to solve this? This is basically the case provided in the org.lejos.example file, refactored to fit my style.

My build.xml file is posted below:
Code: Select all
<project name="Test2" 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="full.main.class" value="${package}.${main.class}" />
   <property name="binary" value="${build}/${main.class}.nxj" />
   <property name="debug" value="${build}/${main.class}.nxd" />

   <path id="lejos.pc">
      <fileset dir="../../lib/pc">
         <include name="**/*.jar" />
      </fileset>
   </path>
   <path id="lejos.nxt">
      <fileset dir="/Users/anthonyreed/lejos_nxj/lib/nxt">
         <include name="**/*.jar" />
      </fileset>
   </path>
   
   <condition property="d32Flag" value="-d32" else="-Dblank.dummy.arg=">
      <and>
         <os family="mac" />
      </and>
   </condition>

   <!-- 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}" includeantruntime="false" verbose="true">
         <bootclasspath refid="lejos.nxt" />
         <!--
            Without this, there are some JDK jars in the classpath.
            Set verbose=true to check that the classpath is really clean.
         -->
          <compilerarg value="-extdirs" />
          <compilerarg value="" />
      </javac>
   </target>

   <target name="link" depends="compile" description="link the binary ">
      <!-- Link the binary and create a signature file  _[b] FAILS ON THE LINE BELOW [/b]-->
      <java classname="lejos.pc.tools.NXJLink" failonerror="true">
         <classpath refid="lejos.pc" />
         <arg value="--bootclasspath" />
         <arg pathref="lejos.nxt" />
         <arg value="--classpath" />
         <arg path="${build}" />
         <arg value="--writeorder" />
         <arg value="LE" />
         <arg value="-o" />
         <arg file="${binary}" />
         <arg value="-od" />
         <arg file="${debug}" />
         <arg value="-v" />
         <arg value="${full.main.class}" />
      </java>
   </target>
   
   <target name="debuglink" depends="compile" description="link the binary">
      <!-- Link the binary and create a signature file -->
      <java classname="lejos.pc.tools.NXJLink" failonerror="true">
         <classpath refid="lejos.pc" />
         <arg value="--bootclasspath" />
         <arg pathref="lejos.nxt" />
         <arg value="--classpath" />
         <arg path="${build}" />
         <arg value="--writeorder" />
         <arg value="LE" />
         <arg value="-o" />
         <arg file="${binary}" />
         <arg value="-od" />
         <arg file="${debug}" />
         <arg value="-gr" />
         <arg value="-v" />
         <arg value="${full.main.class}" />
      </java>
   </target>
   
   <target name="upload" depends="link" description="upload the binary">
      <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="${binary}" />
      </java>
   </target>
   
   <target name="uploadandrun" depends="link" description="upload and run the binary">
      <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="-r" />
         <arg file="${binary}" />
      </java>
   </target>
   
   <target name="debuguploadandrun" depends="debuglink" description="upload and run the binary">
      <java classname="lejos.pc.tools.NXJUpload" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="-r" />
         <arg file="${binary}" />
      </java>
   </target>
   
   <target name="console" depends="debuguploadandrun" description="run a console">
      <sleep seconds="4" />
      <java classname="lejos.pc.tools.NXJConsole" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="-di" />
         <arg file="${debug}" />
      </java>
   </target>
   
   <target name="consoleviewer" depends="debuguploadandrun" description="run the GUI Console Viewer">
      <sleep seconds="4" />
      <java classname="lejos.pc.tools.NXJConsoleViewer" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <jvmarg value="${d32Flag}" />
         <classpath refid="lejos.pc" />
         <arg value="-di" />
         <arg file="${debug}" />
      </java>
   </target>
   
   <target name="debugtool" description="run the debug tool">
        <input
          message="Exception class:"
          addproperty="class"
        />
        <input
          message="Method number:"
          addproperty="method"
        />
        <input
          message="PC value:"
          addproperty="pc"
        />
      <java classname="lejos.pc.tools.NXJDebugTool" fork="true" failonerror="true">
         <jvmarg value="-Dnxj.home=${nxj.home}" />
         <classpath refid="lejos.pc" />
         <arg value="-di" />
         <arg file="${debug}" />
         <arg value="-c" />
         <arg value="-m" />
         <arg value="${class}" />
         <arg value="${method}" />
         <arg value="${pc}" />
      </java>
   </target>
   
   <!-- generate javadocs -->
   <target name="docs" description="generate javadocs">
      <delete dir="${docs}" />
      
       <mkdir dir="${docs}" />
      <javadoc
         destdir="${docs}"
         charset="utf-8"
         locale="en_US"
         author="true"
         access="protected"
         windowtitle="Project documentation"
         verbose="false"
      >
         <classpath refid="lejos.nxt" />
          <arg value="-extdirs"/>
         <arg value="-quiet"/>
         
         <packageset
            dir="${src}"
         />
      </javadoc>
   </target>

   <!--  used only for modifying the Netbeans NXJPlugin -->
   <target name="Zip for Netbeans" description="Zip the application to the sample project">
      <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/**" />
         <exclude name=".project" />
         <exclude name=".classpath" />
      </zip>
   </target>
</project>


I'm using a Mac OSX 10.6.7. Any ideas on how to fix this?

Any help would be greatly appreciated.
codexJava
New User
 
Posts: 1
Joined: Thu Aug 04, 2011 3:47 am

Re: Project creation problem in NetBeans

Postby Rickz2020 » Thu Aug 04, 2011 2:53 pm

Hi,

Navigate you your build.properties file.

It's located in a place like this: C:\Users\Rich\leJOSNXJProjects\myROBOT .....obviously just replace what you need to.

Next, open build.properties in word.

Then, replace "nxj.home=../snapshot" with "nxj.home=${env.NXJ_HOME}".

Save the file and try build your program now.

Regards,

Rich.

NOTE: This is for PC. Hopefully it will work for mac!
Rickz2020
Active User
 
Posts: 121
Joined: Thu Feb 10, 2011 5:47 pm
Location: London, Earth.

Re:

Postby Rickz2020 » Thu Aug 04, 2011 2:57 pm

KittenFace wrote:riiight, the class not found error has been solved and the program is loaded and executable on the nxt even with the remaining presence of the 'ncludeantruntime' error.

what strikes me as odd with the current working, is that there are no compiler errors or anything, despite netbeans claiming that package lejos.ntx doesnt exist!


I think you need to make sure the classpath is correct. As for it still running, perhaps you are not using any lejos classes?
Rickz2020
Active User
 
Posts: 121
Joined: Thu Feb 10, 2011 5:47 pm
Location: London, Earth.

Re: Project creation problem in NetBeans

Postby gloomyandy » Thu Aug 04, 2011 3:41 pm

Do you have a build to properties file? You need one....
Is main.class defined in it? If not then it probably should be...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3993
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re:

Postby Mariam » Tue Nov 29, 2011 8:30 am

[quote="KittenFace"]riiight, the class not found error has been solved and the program is loaded and executable on the nxt even with the remaining presence of the 'ncludeantruntime' error.

Hi, I am facing the same problem, I didn't understand what u did exactly to solve it. Any help ?
Mariam
New User
 
Posts: 11
Joined: Tue Nov 29, 2011 8:27 am

Re: Project creation problem in NetBeans

Postby sioux » Tue Nov 29, 2011 9:27 am

Have you checked the libraries that are used for your project?

If necessary remove any library in the project and add it again manually.
You only need classes.jar for your program to compile. From your errors, i'd say
it is a classpath problem. I can see the program searching for your HelloWorld class in
classes.jar. Ensure your main method is declared correctly and if necessary try to
compile it manually via the command line.

For the .nxj programs, the classes.jar is the library native to the VM on your NXT brick.
So your classpath should look like this.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.lejos.nxt.ldt.LEJOS_LIBRARY_CONTAINER/nxt"/>
<classpathentry kind="output" path="bin"/>
</classpath>

src/ is the folder that your source file is in and bin/ is the one containing the .class compiled file.
I think that your program is trying to find the .class file in the classes.jar
sioux
New User
 
Posts: 8
Joined: Sun Nov 27, 2011 4:19 pm

Re: Project creation problem in NetBeans

Postby Mariam » Mon Dec 12, 2011 6:16 am

sioux wrote:So your classpath should look like this.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.lejos.nxt.ldt.LEJOS_LIBRARY_CONTAINER/nxt"/>
<classpathentry kind="output" path="bin"/>
</classpath>


Sorry for the silly question , where I should find this peace of code ?
I am still facing the problem. I can run the file from the command line but not from netbeans
Mariam
New User
 
Posts: 11
Joined: Tue Nov 29, 2011 8:27 am

Re: Project creation problem in NetBeans

Postby skoehler » Mon Dec 12, 2011 7:36 am

Mariam wrote:Sorry for the silly question , where I should find this peace of code ?

That's a piece of the Eclipse project configuration, not Netbeans.
skoehler
leJOS Team Member
 
Posts: 1410
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 1 guest

more stuff