Skip to main content

External Jar behaviour at runtime

7 replies [Last post]
ashokabk
Offline
Joined: 2008-08-25
Points: 0

Hi,

I am using Netbeans IDE with bdj plugin for my development purpose.

When i add a external jar to this development environment, it wont give any compilation error. ( I'm adding js.jar to build path). But at the runtime, it will give class not found exception. I think the plugin is built like that.

Could you please tell me how can i resolve the issue.

Waiting for the reply,
Ashoka B K

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ashokabk
Offline
Joined: 2008-08-25
Points: 0

Hi Chihiro,

Thanks a lot for your answer.
I am able to set jar to classpath. Now my applictaion is working properly.

Thanks Again
Ashoka B K

ashokabk
Offline
Joined: 2008-08-25
Points: 0

Hi Chihiro,

Thanks for your reply.
You told to update compile target and jar target. But how to do that.
What code i need to add inorder to add my jar to classpath and Xlet path.
The required part of the build.xml file is here.
Plz suggets me the changes

depends="init" description="Compiles the sources">

bootclasspath="${bdj.classes}"
destdir="${build.dir}/classes"
source="1.3" target="1.3"
debug="on" deprecation="on">






depends="compile"
description="Creates an xlet jar file">
basedir="${build.dir}/classes"/>

Thanks
Ashoka B K

chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Hi Ashoka,

http://ant.apache.org/manual/CoreTasks/javac.html
http://ant.apache.org/manual/CoreTasks/jar.html

I guess one way to do it is (assuming xlet.lib.zip is pointing to your js.jar),

bootclasspath="${bdj.classes}"
classpath="${xlet.lib.zip}"
destdir="${build.dir}/classes"
source="1.3" target="1.3"
debug="on" deprecation="on">

....

BTW, make sure that js.jar had been compiled with jdk 1.3 option as well.

Chihiro

agentike
Offline
Joined: 2009-11-08
Points: 0

Hello Chihiro,

I configure my project in the way you described but somehow it doesn't work. I put all the content of the hdcookbook bin folder in one zipfile and referenced it in the build.xml / build.properties:

cookbook.classes=lib/cookbook.zip

depends="init" description="Compiles the sources">

bootclasspath="${bdj.classes}"
classpath="${cookbook.classes}"
destdir="${build.dir}/classes"
source="1.3" target="1.3"
debug="on" deprecation="on">

I also added it to the java sources classpath of my project in netbeans. When I try to import a package the hdcookbook packages are there but when I want to use them there comes an error message that says that the certain package doesn't exist.

Thanks for your help in advance.

Christian

chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Hi Christian,

Changing the setup in Netbeans wouldn't affect the compilation process of the hdcookbook, as it's a free-form ant project.

I don't see anything obviously wrong in your syntax. Could you make sure that the hdcookbook classes (com/hdcookbook/ directory with .class files, essentially) are present in the ${build.dir}/classes directory when you're invoking javac? This means that your "lib/cookbook.zip" should include the hdcookbook classes in it's root directory.

Thanks,
Chihiro

agentike
Offline
Joined: 2009-11-08
Points: 0

Hi Chihiro,

thanks alot for your help. The syntax was totally right, I accidently put the jar files into the zip archive instead of the class files. Works fine now.

chihiro_saito
Offline
Joined: 2006-11-08
Points: 0

Hi,
If you're using the plugin I did, then a generated bdj project becomes a free-form project. It means that you can't change the project compilation properties from netbean's GUI, instead you need to modify build.xml directly. It's something I'd like to update in a near future, actually.
To add a new jar to a BDMV image in the existing plugin, please update (1) "compile" target to add your jar to the classpath, and (2) update "jar" target to add your jar into the xlet jar.
Chihiro