1 Replies - 1203 Views - Last Post: 25 November 2012 - 08:35 PM Rate Topic: -----

#1 freestyler  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 31-March 12

Batch file for NXT Java

Posted 25 November 2012 - 06:29 PM

Hello! I am a moderately experienced Java programmer, and this question is a little out of my field of expertise. I would like to create a batch file to run the following commands in order to upload Java code to an NXT brick through LeJOS, an NXT Java IDE.
nxjc HelloWorld.java

Typically you would open a command prompt and execute this command in the directory in which you created HelloWorld.java.
nxjlink -o HelloWorld.nxj HelloWorld

This will create the file called HelloWorld.class. Unlike a real Java virtual machine, the leJOS firmware does not execute *.class files directly. The HelloWorld program needs to be linked, using the leJOS linker by the command above.
nxjlink -o HelloWorld.nxj HelloWorld

This will load the class HelloWorld (from HelloWorld.class) and all dependencies. The classes are then merged together into a single file, namely HelloWorld.nxj.
nxjupload -r HelloWorld.nxj

You can now upload it to the NXT brick to execute it.

All of the above was aquired (word for word at times) from here, in case I wasn't clear enough. Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Batch file for NXT Java

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon

Reputation: 917
  • View blog
  • Posts: 2,358
  • Joined: 28-March 11

Re: Batch file for NXT Java

Posted 25 November 2012 - 08:35 PM

Have you tried putting all those commands in a bat file and running the bat file?

Of course all those programs should be in your PATH variable.

Or you could set the path to NXT in the bat file.

This "should" work:
@echo off
	%nxtpath%nxjc HelloWorld.java
	if errorlevel 1 goto nxjcerror
	%nxtpath%nxjlink -o HelloWorld.nxj HelloWorld
	if errorlevel 1 goto nxjlinkerror
	%nxtpath%nxjupload -r HelloWorld.nxj
	if errorlevel 1 goto nxjuploaderror	
	goto TheEnd

    echo _
    echo Error with jc
    goto TheEnd

    echo _
    echo Error linking
    goto TheEnd

    echo _
    echo Upload error

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1