dont want to use Eclipse

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

Moderators: roger, 99jonathan, imaqine

dont want to use Eclipse

Postby ramon-bacardi » Sun Dec 16, 2012 3:15 pm

Hi, coleagues. I dont want to use eclipse, but need to compile NXJ code. I am using windows XP platform.

Can you help me to set CLASSPATH ?

I want to use basically 2 classes :
===
import lejos.pc.comm.*;
import lejos.nxt.remote.*;
===

For the second I know I have to use
===
SET CLASSPATH=%CLASSPATH%"c:\Program Files\leJOS NXJ\lib\nxt\classes.jar;"
===

But "lejos.pc.comm.*" seems to be more dificult ...

Thanks. Ramon.

PD.- I have a brand new Java installed
===
c:\>java -version
java version "1.7.0_09"
===

Also have set the envir var
===
LEJOS_NXT_JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09
===
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby gloomyandy » Sun Dec 16, 2012 3:46 pm

Are you trying to compile code that runs on the NXT, or code that runs on the PC?

Either way have you read the instructions in the leJOS tutorial they describe how to use the various .bat files to compile and run leJOS programs from the command line:
http://lejos.sourceforge.net/nxt/nxj/tu ... AndRun.htm

Though I would seriously recommend that you learn how to use eclipse. It can be a complex environment to begin with but you are more likely to get help here, pretty much all of the leJOS developers use eclipse...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: dont want to use Eclipse

Postby ramon-bacardi » Sun Dec 16, 2012 4:47 pm

First answer : I want a program to run on PC. Full stop. Sure.
So, I need to use "lejos.pc.comm.*", true ?
So, my "jars" are "charting.jar, jtools.jar, pccomm.jar, pctools.jar", all located at "c:\program files\leJOS NXJ\lib\pc". So far, so good.

I proceed to read this URL :
>>> http://lejos.sourceforge.net/nxt/pc/api/index.html

But I dont find any function that gives me something similar to ... "getBrickName()" or "getVoltageMilliVolt()" ...
How can I use those functions from PC ?
I am reading "RemoteNXT.java" from "LeJOS NXJ Development Kit Sources", but those functions are reachable from one NXT to another NXT ... as far as i see.

The URL you provide
>>> http://lejos.sourceforge.net/nxt/nxj/tu ... AndRun.htm
states clearly that "leJOS NXJ also supports programs that run on the PC and control a NXT robot remotely" - exactly what I want to do.
But I cant find any samples.
Can someone provide a sample or a pointer or a URL ?

Thanks. Ramon.
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby ramon-bacardi » Sun Dec 16, 2012 6:11 pm

Hi, coleagues

I have found a nice page, where mr "gloomyandy" also participated ...
>>> viewtopic.php?f=5&t=3397

... where they teached me 2 items :

1) to use nxjpcc and nxjpc ...

2) to use "direct commands" .. seems EXACTLY what I want ... but ... WHERE IS IT DOCUMENTED ???

Thanks. Ramon.

PD.- another question : I get the message

===
\\LEGO\Java\direct-command> nxjpc NXTmotorFWD
BlueCove version 2.1.0 on widcomm
Failed to open connection to the NXT
BlueCove stack shutdown completed
===

... Is it possible to use USB instead of BlueTooth ? What must I change ??
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby gloomyandy » Sun Dec 16, 2012 6:35 pm

The documentation is exactly where you looked before...
http://lejos.sourceforge.net/nxt/pc/api/index.html
To get the battery state use the Battery class:
http://lejos.sourceforge.net/nxt/pc/api ... ttery.html
To get the brick name use the NXT class
http://lejos.sourceforge.net/nxt/pc/api ... t/NXT.html

The samples are provided as part of leJOS and you should have had the option to install them when you installed leJOS. See the tutorial:
http://lejos.sourceforge.net/nxt/nxj/tu ... indows.htm
You can also browse the latest version of the samples on line:
http://sourceforge.net/p/lejos/code/693 ... pcsamples/

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: dont want to use Eclipse

Postby ramon-bacardi » Sun Dec 16, 2012 6:49 pm

Thanks, Andy - I do appreciate your patience.
And want to answer my own question : to compile and run PC programs, it is better to use the good tools ... nxjpcc (compile) and nxjpc (run).
Ramon.
PD.- the problem I had with the documentation comes tfrom the fact that in /nxt/pc/ it says nothing about NXT elements you can use.
They are in /nxt/nxj/ and I thought they were to be used when programming some code to go into the NXT brick.
I find no reference of "direct commands" in the API, jejeje
Best luck.
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby skoehler » Tue Dec 18, 2012 3:02 pm

NEVER include classes.jar in the classpath of a program that runs on the PC. Also, no one really uses the CLASSPATH environment variable anymore. If you really want to any kind of IDE, at least use ant to build/run your application. Or maven or whatever you're an expert on. Examples build.xml files are provided with our example projects.

In order to run application that run on the PC, add all jars in the subdirectory lib/pc to your classpath. Nothing more is required to compile/run a program that uses on the PC.

Compiling and linking programs that run on the NXT is a completely different matter, and requires messing around with the bootclasspath. Most IDEs (especially Netbeans) not support that without much effort. Hence, we only provide Eclipse support at the moment.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: dont want to use Eclipse

Postby ramon-bacardi » Sat Dec 22, 2012 10:56 am

Thanks, mr skoehler - I will try to use "ant" - can you provide a pointer to some samples ?
By the moment, I use "nxjpcc" and "nxjpc" from command line - I dont like eclipse, sorry.
Now I can read BrickName and BatteryVoltage correctly - thanks to you help, of course.

Next I want to try is to send to a mailbox from NXT and receive it into the PC program.
In file "MonitorTest.java" I found a sample on how to use "messageWrite()" from NXT.
The sample on how to use "messageRead()" from PC I have found is "NXJMonitor.java".
And I think I will be able to make them work. This shall be some kind of "status communication status".

But, my problem is that I want to have a similar communication channel from PC to NXT, to send some "orders", AT THE SAME TIME that "status" comes from NXT to PC using first program.

Can you provide any clue ?

If I have in PC a program running called "ReceiveStatus" ... I can run another called "SendCommands" on a diferent command prompt.
BUT WILL THIS SECOND PROGRAM GET CONNECTED TO NXT ?
And most important : how can I code the "listener" in the brick ?

The problem comes from the fact that I have a program on PC, reading the BrickName and/or BatteryVoltage from NXT ... BUT I HAVE NO CODE IN nxt except leJOS.
Who is answering those values ?
I still dont find any documentatin abbout "direct commands" anywhere ...

Thanks a lot !
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby skoehler » Sat Dec 22, 2012 5:46 pm

ramon-bacardi wrote:Thanks, mr skoehler - I will try to use "ant" - can you provide a pointer to some samples ?


Part of every leJOS install is a file called "samples.zip". In this file, you will find two example projects. These are the ideal templates for your own projects, and they include a build.xml that's ready to use. If, for some reason, you can't find that file, you can redownload it from our download page.
As you're not going to use Eclipse, you can delete all eclipse specific files from the example projects (.classpath, .project, .settings).

ramon-bacardi wrote:By the moment, I use "nxjpcc" and "nxjpc" from command line - I dont like eclipse, sorry.


That's a pity. So what are you using instead of Eclipse? Notepad? Netbeans?


ramon-bacardi wrote:But, my problem is that I want to have a similar communication channel from PC to NXT, to send some "orders", AT THE SAME TIME that "status" comes from NXT to PC using first program.


As far as I know, the NXT has outbound AND inbound message queues. I.e. you can post messages to some of the queues while you can only read from others.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: dont want to use Eclipse

Postby ramon-bacardi » Wed Jan 02, 2013 10:25 am

1) ant & samples.zip : perfect,thanks a lot

2) no-Eclipse : jajaja, I am an UE fanatic ... no NetBeans, thanks

3) queues - yes, I know there are 2 kind of queues. My problem is how to send to a PC and "simultaneously" receive from PC on the other queue !
The documentation on inbound and outbound queues is quite incomplete in my humble opinion ...
As ... if I write 2 programs on PC (one to send, the other to receive) ... will them BOTH be able to connect to NXT simultaneously ?

Nice 2013 to you all !!
ramon-bacardi
New User
 
Posts: 6
Joined: Fri Dec 07, 2012 9:45 am

Re: dont want to use Eclipse

Postby skoehler » Wed Jan 02, 2013 10:31 am

ramon-bacardi wrote:2) no-Eclipse : jajaja, I am an UE fanatic ... no NetBeans, thanks


UE is short for ...?

ramon-bacardi wrote:3) queues - yes, I know there are 2 kind of queues. My problem is how to send to a PC and "simultaneously" receive from PC on the other queue !

I don't understand you problem. You could use two threads (even though I think the API might not be threadsafe) or you simply have a single thread, that polls the outbound queue of the NXT and inbetween polls send any messages to the inbound queue of the NXT.

ramon-bacardi wrote:As ... if I write 2 programs on PC (one to send, the other to receive) ... will them BOTH be able to connect to NXT simultaneously ?

That is neither supported nor needed.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: dont want to use Eclipse

Postby gloomyandy » Wed Jan 02, 2013 2:52 pm

Hi,
I think you will get more help if you describe what exactly it is you are trying to do. The Mailbox support is not really intended for programs that have leJOS components at each end of the connection, it was provided primarily as a way for leJOS programs to be able to interact with programs using the Lego software. If you have leJOS code on both sides of the connection then there are probably better ways to do things than the mailbox api...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: dont want to use Eclipse

Postby Docta_J » Sun Jan 06, 2013 4:09 am

I am an amateur programmer, fairly new to to java and Lejos. I have just finished stumbling through a similar problem, and received some excellent help from the folks at javaranch. My goal for this project was to use a console on a W7 machine to write characters a line at a time to the NXT, using lejos at both ends. To prove it worked, I output the string to the LCD and return it to the PC console. I ran into a number of problems trying to compile without using Eclipse. I had to work outside of eclipe because I had a great deal of trouble sending a reliable end-of-line character using the eclipse console.

Lessons I have learned: I had to re-install java and Lejos into directories that did NOT have spaces in their names. That is, W7 tries to place the programs in a subdirectory of 'C:\Program Files (x86)'. The spaces in the directory name prevented the command line commands of nxjc and nxjpcc from finding the classes. Once I installed the java and Lejos directly beneath C:\, things went smoother.

There are certainly many ways to communicate between the pc and NXT. I post below the programs I have written. PC_BT_Connect.nxj is for the W7 side, and BTReceive2.nxj uploads to the NXT. I ran into trouble with stray initial characters in my responses back to the PC from the NXT. This occurred due to my use of DataInput[Output]Streams. This resolved when I was guided to use input/outputStreams, streamreaders and buffered streams. My next step will be a starting this in a separate thread.

The working code is posted at http://www.coderanch.com/t/601782/java/java/Unexpected-leading-characters-buffered-reader

Hopefully, some of this information is helpful to you.

--John
Docta_J
New User
 
Posts: 10
Joined: Sat Jul 07, 2012 3:15 am
Location: North Dakota, USA

Re: dont want to use Eclipse

Postby skoehler » Sun Jan 06, 2013 5:25 am

Docta_J wrote:Lessons I have learned: I had to re-install java and Lejos into directories that did NOT have spaces in their names. That is, W7 tries to place the programs in a subdirectory of 'C:\Program Files (x86)'. The spaces in the directory name prevented the command line commands of nxjc and nxjpcc from finding the classes. Once I installed the java and Lejos directly beneath C:\, things went smoother.


That should not happen with leJOS 0.9.1, and if it does, this is a bug. Please tell me exactly what failed, when you installed leJOS to c:\program files.
skoehler
leJOS Team Member
 
Posts: 1110
Joined: Thu Oct 30, 2008 4:54 pm

Re: dont want to use Eclipse

Postby Docta_J » Sun Jan 06, 2013 6:35 pm

I will re-install and try to recreate the event. --John
Docta_J
New User
 
Posts: 10
Joined: Sat Jul 07, 2012 3:15 am
Location: North Dakota, USA

Next

Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 8 guests

more stuff