[Problem] - Uploading files and using objects

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

Moderators: 99jonathan, roger, imaqine

[Problem] - Uploading files and using objects

Postby Shinigami » Thu Oct 25, 2007 3:30 pm

We're using the lego NXT for the very first in one discipline.

Trying to use Oriented-Object (Java) became a problem, we can't even upload a class because it does not have a main.

What's the real problem, why can't we Upload files without a main? We want to work without inner classes, every object has it owns class.

Can we use objects? Can we create packages? How to upload them? We are using usb port.

Ps: Message at uploading (Nameoftheclass doesn't have static voidmain (String[]) method
Ps2: Does it needs to have an mpty main?

I'll wait for the answers so since now thanks for any help.
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm

Postby cbadenh » Thu Oct 25, 2007 4:29 pm

IMHO: The java code needs to be compiled and linked into a single .NXJ file using the lejos batch files before it is sent to the NXT brick. I think you just have the order wrong on your steps. It appears that you are trying to do: write, upload, compile, link, and run (where upload is where you move the source from your development machine to the NXT). But in reality you need to do: write, compile, link, and THEN upload and run. Lejos is expecting that you will be uploading the linked byte code, not the source code nor individual object code.

Once you generate your source code, you just need to give the lejos batch files the class file with your main entry point. From this file, the compiler/linker will add referenced class files that are on your class path so you don't have to worry about each individual file in a package that your program uses.
cbadenh
New User
 
Posts: 3
Joined: Thu Oct 18, 2007 3:37 pm

Postby Shinigami » Thu Oct 25, 2007 4:59 pm

How can we link the classes to the main?
What we did last time:
Compile, upload, run. Web compiled every class of the program but we had to put a static void main in them, is it right? Will the main Program use the othe classes with the empty main?

Anyway, thanks for your help!
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm

Postby Shinigami » Thu Oct 25, 2007 5:14 pm

Finally found something about it :o

Re: Linking classes without main(String[])
Subject: Re: Linking classes without main(String[])
List-id: General Q&A about leJOS <lejos-discussion.lists.sourceforge.net>
Nick,

You don't need to list the classes to link them - you just give the main class and if the others are referrred to and on the CLASSPATH, they will be found. The list of classes is only used for downloading multiple independent programs, selected using the Pgrm button. In this case each program must have a main method.

Lawrie



Worked! Thanks for all :D
Any problem and I'll come back :lol:
Shinigami
New User
 
Posts: 6
Joined: Thu Oct 25, 2007 3:16 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 4 guests

more stuff