External Jar libraries on EV3

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

Moderators: roger, gloomyandy, skoehler

josso82
New User
Posts: 2
Joined: Thu Sep 08, 2016 6:58 pm

External Jar libraries on EV3

Postby josso82 » Thu Sep 08, 2016 9:55 pm

Hi All i've tried everything in my mind and i cant make it work. I'm want to build a program that needs external jar file libraries but when i run the program on the brick always shows an error. Then i looked that it looks like the brick doesnt know where to find those libraries so

1.- i added the lib jar files to /home/root/lejos/ejre1.7.0_60/lib/ext/ as some user suggested (not working) i thought that just adding them here will be autoamtically recognized but no so
2.- i tried to change the class path in eclipse and didnt succeded
3.- i opened the hello world example and unzip... and looking the manifest i can see the path for the current lib on the program (dont know how to add the path for the new jars)
4.- i tried to configure build path - libraries - native library location (on the added jars) didnt work
5.- ctrl + shift + R - .classpath and here it shows some paths (example: org.lejos.ev3.ldt.LEJOS_EV3_LIBRARY_CONTAINER) but the real ev3 library on thhe brick is /lejos/lib.... so i dont know where that path is added

thanks all for the support.

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

Re: External Jar libraries on EV3

Postby gloomyandy » Fri Sep 09, 2016 9:20 am

Have you read the following thread:
viewtopic.php?f=18&t=7794

What version of leJOS are you using? Are you using the leJOS eclipse plugin?

Oh and what external jar file are you trying to add? If it contains any native code it will almost certainly not work. If you still having problems after following the above post (and after removing any changes you have made to try and fix the problem), then post the stack trace you are getting.
leJOS news https://lejosnews.wordpress.com/

josso82
New User
Posts: 2
Joined: Thu Sep 08, 2016 6:58 pm

Re: External Jar libraries on EV3

Postby josso82 » Fri Sep 09, 2016 2:07 pm

thanks for the reply Andy

i did read that thread before posting my question but non of the solutions on it worked for me. i do have the leJOS plugin for eclipse and that is what i'm using to develop and test on the brick. the version of lejos im using is EV3 0.9.1

the jar files i'm trying to use are from an SDK for a software called ThingWorx and those able connectivity to that IoT Platform. I know the can work on the brick as a teammate from japan made it work (but trying to reach him is really hard)

i read in the thread a post comment: "Referenced JARs are now uploaded automatically to the brick if you choose "Run as... LeJOS EV3 program" using LeJOS 0.9.1 beta." does this means that external jar files are "sent" to the brick? in that case in the manifest of the jar that is sent to the brick those jars doesnt have a reference

and a last question...for running a java file from the terminal we can use java -jar myjar.jar can this be done in the brick? as somebody told me i could construct the claspath in the command above

thanks

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

Re: External Jar libraries on EV3

Postby gloomyandy » Fri Sep 09, 2016 4:29 pm

If you use the leJOS eclipse plugin then external jars will be copied to the brick when you download and run the program. They will not be placed inside the jat but will be copied as a separate file to the EV3. The classpath of the program will be set so as to include the referenced jars.

Yes you can run leJOS programs from the Linux command line. Just use ssh to login to the EV3 and use the jrun command to execute the program. You can use the -cp option to add files to the classpath. Note however that you can't use this with the -jar command line option. If you intend to use the command line you should probably read the following:
http://stackoverflow.com/questions/1593 ... ath-option
leJOS news https://lejosnews.wordpress.com/

aschulze
New User
Posts: 18
Joined: Wed Aug 17, 2016 1:22 pm

Re: External Jar libraries on EV3

Postby aschulze » Thu Sep 15, 2016 7:02 pm

I have no trouble using external JARs by using the following setup (LeJOS 0.9.1 beta, Eclipse 4.5.2):
1. Added a simple project (General/project) called "LibraryProject"
2. Added the required JAR files to the LibraryProject
3. Added the required JAR to the build path of my LeJOS project using Project preferences -> Java Build Path -> Libraries -> Add JARs

As soon as a use "Run as... LeJOS EV3 program" the library is automatically loaded to the brick and the classpath is set correctly.

ruperty
Advanced Member
Posts: 181
Joined: Sun Oct 14, 2007 11:21 am

Re: External Jar libraries on EV3

Postby ruperty » Thu Feb 08, 2018 11:54 am

aschulze wrote:I have no trouble using external JARs by using the following setup (LeJOS 0.9.1 beta, Eclipse 4.5.2):
1. Added a simple project (General/project) called "LibraryProject"
2. Added the required JAR files to the LibraryProject
3. Added the required JAR to the build path of my LeJOS project using Project preferences -> Java Build Path -> Libraries -> Add JARs

As soon as a use "Run as... LeJOS EV3 program" the library is automatically loaded to the brick and the classpath is set correctly.


I used to use an ant script for transferring external jars for a project, and I then had to modify jrun.

For the record, I have now tried this above process and it works well, by uploading the external jars and adding them to the classpath in the project jar manifest.

One thing I have noticed though is that the jar classpath is not picked up if variables are used.

Image

As shown here I use a classpath variable USERHOME which caters for different locations on different machines. However, these paths are ignored and the jars not uploaded. So I have had to revert to using the direct path, which gives errors on a different machine.

Is this something that could be addressed in a future release?
Regards,
Rupert
www.perceptualrobots.com

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

Re: External Jar libraries on EV3

Postby gloomyandy » Thu Feb 08, 2018 3:21 pm

It probably could be addressed, however, I'm not sure there will ever be an updated release, there has been very little activity over the last year or so. But who knows perhaps someone will take it on!
leJOS news https://lejosnews.wordpress.com/


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 1 guest