Netbeans and NXT

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

Moderators: 99jonathan, roger, imaqine

Netbeans and NXT

Postby epokh » Wed Apr 25, 2007 3:32 pm

I often use netbeans (now 5.5) for my java develop.
It's so easy to add the jar as library in a new java project.
So I'm using it and it's good. I was wondering if there's a way to change the compiler for the project. So instead of using the java standard compiler I would use the lejos one.
Does somebody have managed it?
Cheers
epokh
Novice
 
Posts: 26
Joined: Wed Feb 21, 2007 5:46 pm

Postby bbagnall » Wed Apr 25, 2007 4:28 pm

You'll probably get your answer more quickly by asking on a NetBeans forum.
User avatar
bbagnall
Site Admin
 
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Postby imaqine » Wed May 16, 2007 6:18 pm

Make sure to post the information you get from the netbeans forum on here so users using leJOS will know how to use netbeans and LeJOS if the choose to.
imaqine
Moderator
 
Posts: 79
Joined: Sun Apr 08, 2007 6:20 am

Use an ANT script project with the following build.xml

Postby bowser » Wed Jul 11, 2007 1:11 pm

<?xml version="1.0" encoding="UTF-8"?>
<!--
NB you will have to change the run.class variable to the name of the class which contains the public static void main(...

place this build.xml file in a directory. create the following folders
src //contains the *.java files and packages etc
tests //contains the junit tests
lib // copy the classes file from lejos_home/lib, and the junit-8.3.1.jar from somewhere...

In NetBeans, create a new project with ANT script, locate the directory with this build file, add the contents of the lib directory to the classpath when asked..
Compiling single files requires a fix, first try compiling a single file (f9) and answer 'ok' then close netbeans and alter the project.xml file which netbeans creates... in the nbproject directory e.g.
<action name="compile.single">
<script>build.xml</script>
<target>compile-selected-files-in-src</target>
...
Start NetBeans with the project, now clean, build run work as normal!
NB this works on most windows platforms, I am sure a Linux person can add an appropriate <exec for the run target....
Problem with the JUnit tests, no autocomplete as yet... help.....
You may want to change name="NXJ" to something more descriptive for your project
-->

<project name="NXJ" default="default" basedir="." >
<property environment="env" />
<property environment="myenv" />
<property name="src.dir" value="src" />
<property name="build.dir" value="support/build" />
<property name="dist.dir" value="support/dist" />
<property name="dist.javadoc.dir" value="support/javadoc" />
<property name="build.classes.excludes" value="support/excludes" />
<property name="dist.jar" value="support/dist.jar" />
<property name="test.src.dir" value="tests" />
<property name="run.class" value="M" />
<property name="lejos.home" value="${myenv.LEJOS_HOME}" />
<property name="junit.jar" value="lib/junit-8.3.1.jar" />
<property name="test.classes.dir" value="support/testClasses" />
<property name="test.results.dir" value="support/testResults" />



<target name="default" depends="javadoc,run" description="Build and test whole project.">
</target>

<target name="create_dirs" depends="clean">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.javadoc.dir}" />
<mkdir dir="${build.classes.excludes}" />
<mkdir dir="${test.classes.dir}" />
</target>
<target name="compile" depends="create_dirs" description="Compile the whole project.">
<javac srcdir="${src.dir}"
destdir="${build.dir}"
source="1.3"
target="1.1"
bootclasspath="${lejos.home}/lib/classes.jar;${myenv.CLASSPATH}"
/>
</target>
<target name="build" depends="compile" description="Build whole project.">
<property name="thirdparty.lib" value="${lejos.home}/3rdparty/lib" />
<property name="link.classpath" value="{$thirdparty.classpath}/bcel-5.1.jar;${thirdparty.lib}/commons-cli-1.0.jar;${lejos.home}/lib/jtools.jar;${lejos.home}/lib/classes.jar;" />
<exec dir="${build.dir}" executable="cmd" os="Windows XP,Windows NT,Windows 2000,Windows 2003">
<arg line="/c ${lejos.home}/bin/lejoslink ${run.class} -o ${run.class}.lej"/>
</exec>
<echo message="${os.name}" />
<exec dir="${build.dir}" executable="bash" os="Linux" >
<arg line="${lejos.home}/bin/lejoslink ${run.class} -o ${run.class}.lej"/>
</exec>
</target>


<target name="do-clean" >
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${dist.javadoc.dir}" />
<delete dir="${build.classes.excludes}" />
<delete dir="${test.classes.dir}" />
<echo message="${os.name}" />
</target>

<target name="-init-check">
<fail unless="src.dir">Must set src.dir</fail>
<fail unless="test.src.dir">Must set test.src.dir</fail>
<fail unless="build.dir">Must set build.dir</fail>
<fail unless="dist.dir">Must set dist.dir</fail>
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
</target>

<target name="clean" depends="-init-check,do-clean" description="Clean build products." />

<target name="run" depends="build" description="Build and run whole project.">
<exec dir="${build.dir}" executable="cmd" os="Windows XP,Windows NT,Windows 2000,Windows 2003">
<arg line="/c ${lejos.home}/bin/lejosdl ${run.class}.bin"/>
</exec>
<echo message="${os.name}" />
<exec dir="${build.dir}" executable="bash" os="Linux" >
<arg line="${lejos.home}/bin/lejosdl ${run.class}.bin"/>
</exec>
</target>

<target name="emulate" depends="build" description="Emulates the code on a LINUX os implementation of the NXT">
<echo message="${os.name}" />
<exec dir="${build.dir}" executable="bash" os="Linux" >
<arg line="${lejos.home}/bin/emj -v ${run.class}.lej"/>
</exec>
<exec dir="${build.dir}" executable="cmd" os="Windows XP,Windows NT,Windows 2000,Windows 2003">
<arg line="/c echo 'Not implemented of Windows yet'"/>
</exec>
</target>

<target name="rebuild" depends="clean,build" description="Build and test whole project.">
</target>

<target name="-javadoc-build" >
<mkdir dir="${dist.javadoc.dir}" />
<javadoc classpath="${lejos.home}/lib/classes.jar;${myenv.CLASSPATH}" destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" failonerror="true" useexternalfile="true">
<classpath>
<path path="${javac.classpath}" />
</classpath>
<sourcepath>
<pathelement location="${src.dir}" />
</sourcepath>
<packageset dir="${src.dir}" includes="*/**" />
<fileset dir="${src.dir}" includes="*.java" />
</javadoc>
</target>
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="-javadoc-build">
<nbbrowse file="${dist.javadoc.dir}/index.html" />
</target>

<target name="javadoc" depends="clean,build,-javadoc-build,-javadoc-browse" description="Build Javadoc." />


<target name="compile-tests" depends="compile">
<javac srcdir="${test.src.dir}"
destdir="${test.classes.dir}"
source="1.3"
target="1.1"
classpath="${junit.jar};./;.;${build.dir}"
bootclasspath="${lejos.home}/lib/classes.jar;${myenv.CLASSPATH}"
/>

</target>
<target name="test" depends="compile-tests">
<delete dir="${test.results.dir}" />
<mkdir dir="${test.results.dir}"/>
<junit showoutput="true"
fork="true"
failureproperty="tests.failed"
errorproperty="tests.failed">
<batchtest todir="${test.results.dir}">
<fileset dir="tests">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
<classpath path="./;.;${build.dir};${junit.jar};${test.classes.dir}"/>
<formatter usefile="false" type="brief"/>
<formatter type="xml"/>
</junit>
</target>

<target name="compile-selected-files-in-src">
<fail unless="files">Must set property 'files'</fail>
<mkdir dir="${build.dir}"/>
<javac includes="${files}"
srcdir="${src.dir}"
destdir="${build.dir}"
target="1.1"
source="1.3"
bootclasspath="${lejos.home}/lib/classes.jar;${myenv.CLASSPATH}"
/>
</target>


</project>
bowser
New User
 
Posts: 11
Joined: Thu Jul 05, 2007 1:53 pm
Location: UK

Re: Netbeans and NXT

Postby skoehler » Wed Nov 23, 2011 4:11 pm

NetBeans support is pretty limited compared to Eclipse. Sorry for that, but we don't have the resources to developer a proper plug-in. And out of the box, Netbeans doesn't support leJOS development for various reasons. Note that using a proper build.xml doesn't keep the IDE from thinking that you're actually writing an application that will run on the PC (and hence an application that is based on the full-fledged JDK instead of the limited subset that is the leJOS runtime). Move on to Eclipse, which is properly supported.
skoehler
leJOS Team Member
 
Posts: 1406
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff