Ask Your Question
0

Do I need to add jar path in build.gradle???

asked 2012-11-02 00:32:52 -0500

safzam gravatar image

updated 2012-11-06 00:41:26 -0500

Hi, I want to use some java classes from a jar file. If I import them I get error. I also export the CLASSPATH of the jar's path but does not help. Do I need to add the jar file path somewhere like in build.gradle or do I need to put this jar file in some other directory and access it there? Any hints please. Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2012-11-06 00:38:11 -0500

If your jar files are in the lib/ folder, you can add these lines to your build.gradle:

dependencies {
  compile fileTree(dir: 'lib', include: '**/*.jar')
}
edit flag offensive delete link more

Comments

Hi Martin, do you mean that I should make a lib/ folder inside the package and put it my jar file in there? "my.jar" file is in "home/robo/my_stack/jar/my.jar" while the build.gradle is "home/robo/my_stack/my_pkg/build.gradle". Can I use this path?

safzam gravatar image safzam  ( 2012-11-06 09:52:52 -0500 )edit

Personally, I think it's cleaner if the jar file is inside your package, but you could of course also alter the path: compile fileTree(dir:'../jar/my.jar', ...).

Martin Günther gravatar image Martin Günther  ( 2012-11-07 01:02:40 -0500 )edit

Thanks a lot.

safzam gravatar image safzam  ( 2012-11-07 02:01:52 -0500 )edit

I put my jar file in the build/install/rosjava_tutorial_pubsub/lib where all the other jars were present. I also added the following line to my build.gradle file--compile fileTree(dir: 'build/install/rosjava_tutorial_pubsub/lib', include: 'lin.jar') Do i need to make changes in the package.xml as well?

uzair gravatar image uzair  ( 2014-01-18 13:19:51 -0500 )edit

@uzair: This answer was about the Fuerte, pre-catkin version of rosjava (and by 'lib' I meant a new subdirectory of your package). The Groovy/Hydro version of rosjava uses catkin and is much different, so I don't know how things work there. Best ask a new question.

Martin Günther gravatar image Martin Günther  ( 2014-01-18 20:16:53 -0500 )edit

@martin : It all works now. I just had to add this in my build.gradle in the dependencies{}. "compile files('lib/myjar.jar')"

uzair gravatar image uzair  ( 2014-01-20 18:24:17 -0500 )edit

In that case, my solution should also work (and you don't have to specify each jar file separately).

Martin Günther gravatar image Martin Günther  ( 2014-01-20 19:12:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-11-02 00:32:52 -0500

Seen: 9,658 times

Last updated: Nov 06 '12