Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

JNI and

Thread view: 
yshamama@magicsoftware.com - 14 Jun 2005 16:50 GMT
Hi all

I am using java from C++ using JNI calls
the JVM created when the C++ application is started
and destroyed just before it stop running

While my C++ app is running I am creating new class in java
and I want to use them using JNI calls
but the I can't found the class because its not in the classpath

what should I do ???

thanks
Gordon Beaton - 14 Jun 2005 16:53 GMT
> While my C++ app is running I am creating new class in java and I
> want to use them using JNI calls but the I can't found the class
> because its not in the classpath

Specify a classpath argument when you create the JVM.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

yshamama@magicsoftware.com - 15 Jun 2005 06:57 GMT
Hi

Thanks for your quick reply but my problem is that my classes is in a
jar file
and I don't have the location of the jar when I'm creating the JVM.
I get is location only after I alreay create the JVM.
I need a way to load the classes in that jar after I create the JVM
even if the jar file is not the classpath.

Thanks
Chris Uppal - 15 Jun 2005 08:51 GMT
shamama@magicsoftware.com wrote:

> [..] but my problem is that my classes is in a jar file
> and I don't have the location of the jar when I'm creating the JVM.

Then your problem is /exactly/ the same as it would be if you were working in
Java directly, nothing whatever to do with JNI.  The solution is also exactly
the same: create your own classloader (probably a java.net.URLClassLoader) and
use that to load code from the jar file.

(Actually you do have another option using JNI -- you could extract the
classfiles from the JAR file and then inject the bytecode into the JVM directly
using the DefineClass() function in JNI.  Offhand, I can't think of any good
reason for wanting to do it that way, though.)

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.