Problem calling java from vb via activex bridge

I am trying to call java from vb via ActiveX Bridge and I am running into problems. I would appreciate any help.
I am using Visual Basic 2010 express, and Java JDK 1.6.0_16. I have used the http://download.oracle.com/javase/1.4.2/docs/guide/beans/axbridge/developerguide/index.html page as a guideline. To try to make it work I took the following steps:
1. Wrote a very simple java class (below):
package xxx;
import java.io.Serializable;
public class axb implements Serializable {
public int get_axb_Handle() {
int Address = 12345678;
return Address;
2. After I compiled, and created the jar file. I built the dll using the following command:
"C:\Program Files\Java\jdk1.6.0_16\bin\packager" -out "C:\Program Files\Java\jdk1.6.0_16\jre\axbridge\bin" E:\axb\dist\axb.jar xxx.axb
3. I then registered using: regsvr32 axb.dll
4. In Visual Basic Express IDE I use Project -> Add Reference to add Iterop.axb (dump below), and axb namespace
5. In my basic code I use the following lines
Dim axb1 As axb.axb
axb1 = New axb.axb <== Crash here with AccessViolationException ( full exception below)
What am I missing? Any help would be greatly appreciated
Thanks
Iterop.axb partial dump
___[MOD] C:\Documents and Settings\Elie A. Cohen.USINC022\My Documents\Visual Studio 2010\Projects\Repo API Example\Repo API Example\obj\x86\Release\Interop.axb.dll
| M A N I F E S T
|___[NSP] axb
| |___[INT] axb.axb
| | | .class interface public abstract auto ansi import /*02000006*/
| | | implements axb.axbDispatch/*02000003*/
| | | implements axb.axbSource_Event/*02000005*/
| | | .custom /*0C000018:0A000001*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.GuidAttribute/*01000002*/::.ctor(string) /* 0A000001 */ = ( 01 00 24 34 45 36 44 30 44 41 38 2D 36 41 45 44 // ..$4E6D0DA8-6AED ...
| | | .custom /*0C000019:0A000007*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.CoClassAttribute/*01000009*/::.ctor(class [mscorlib/*23000001*/]System.Type/*01000007*/) /* 0A000007 */ = ( 01 00 0C 61 78 62 2E 61 78 62 43 6C 61 73 73 00 // ...axb.axbClass. ...
| |
| |___[CLS] axb.axbClass
| | | .class public auto ansi import /*02000004*/
| | | implements axb.axbDispatch/*02000003*/
| | | implements axb.axb/*02000006*/
| | | implements axb.axbSource_Event/*02000005*/
| | | .custom /*0C00000F:0A000008*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.ClassInterfaceAttribute/*0100000A*/::.ctor(int16) /* 0A000008 */ = ( 01 00 00 00 00 00 ) ...
| | | .custom /*0C000010:0A000009*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.ComSourceInterfacesAttribute/*0100000B*/::.ctor(string) /* 0A000009 */ = ( 01 00 0F 61 78 62 2E 61 78 62 53 6F 75 72 63 65 // ...axb.axbSource ...
| | | .custom /*0C000011:0A000001*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.GuidAttribute/*01000002*/::.ctor(string) /* 0A000001 */ = ( 01 00 24 43 44 42 46 36 42 33 33 2D 45 32 33 46 // ..$CDBF6B33-E23F ...
| | | .custom /*0C000012:0A000002*/ instance void [mscorlib/*23000001*/]System.Runtime.InteropServices.TypeLibTypeAttribute/*01000003*/::.ctor(int16) /* 0A000002 */ = ( 01 00 02 00 00 00 ) ...
| | |___[MET] method .ctor : void()
| | |___[MET] method equals : bool(object)
| | |___[MET] method getClass : object()
| | |___[MET] method get_axb_Handle : int32()
| | |___[MET] method hashCode : int32()
| | |___[MET] method notify : void()
| | |___[MET] method notifyAll : void()
| | |___[MET] method toString : string()
| | |___[MET] method wait : object(object,object)
AccessViolationException exception
System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=mscorlib
StackTrace:
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at WindowsApplication1.Form1.getPatientHandle_Click(Object sender, EventArgs e) in C:\Documents and Settings\Elie A. Cohen.USINC022\my documents\visual studio 2010\Projects\Repo API Example\Repo API Example\Repo API Example.vb:line 13
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

In case you haven't figured it out already... Or if anyone else is curious... Or for myself when I get old and forgetful...
h2. Object Creation
For starters, when you create an ActiveX object from within VB, use:
Set myObject = CreateObject("JavaObject.Bean")When I refer to JavaObject.Bean, I'm meaning the full object name + ".Bean". So, in your case, you should use:
Set myObject = CreateObject("xxx.axb.Bean")h2. Location
The .dll file must be located in the JRE that is used at the time of calling. Meaning, the .dll file must be placed under <jre_home>\axbridge\bin and registered there.
In your case:
DLL:
C:\Program Files\Java\jre6\axbridge\bin
Jar:
C:\Program Files\Java\jre6\axbridge\libh4. A Note:
The only supported JRE is a 32bit version as far as I know with regards to the ActiveX bridge. Just like the packager.exe can only be found in the 32bit JDK.
h2. Methods
h3. Object Types
ActiveX Bridge does not support passing literals or arrays. However, it does support passing java's primitive data types as Objects.
Simply meaning:
h4. Invalid:
public int get_axb_Handle() {
     int Address = 12345678;
     return Address;
}h4. Valid:
public Integer get_axb_Handle() {
     int Address = 12345678;
     return Address;
}On a normal circumstance, there's little difference between the two methods. However, in the second example, the JVM does a typecast from a literal data type to a object data type, resulting in a valid object to pass through to Visual Basic. Now, obviously there are multiple ways to do a proper change, new Integer(int) for example. It doesn't matter to me. At the end of the day, you have to pass an object.
As a side note, the same idea applies when receiving data from Visual Basic.
h4. Invalid:
public void set_axb_Handle(int newHandle) {
     int Address = newHandle;
}h4. Valid:
public void set_axb_Handle(Integer newHandle) {
     int Address =newHandle;

Similar Messages

  • Calling Java from Delphi via JNI

    Hi all. I've got a J2EE application, and I'm trying to write a Delphi client for the server. More specifics:
    Server and test client running in Win2000 SP4.
    Server running in JBoss (JUnit test cases have successfully connected to the server)
    JDK 1.4
    I'm using some Delphi files from JEDI which allow me to load/access a JVM via JNI. So far, I've been able to:
    1) Create a Properties object.
    2) Populate the Properties object with String values (making sure to use NewStringUTF to pass into the Properties method
    3) Find my java client classes which facilitate opening a connection.
    However, when I attempt to call the method on the object which actually creates the connection, I get an Exception.
    My immediate question is how do I see what the Exception is? I have an Exception object, but ExceptionDescribe doesn't product anything, and I'm having trouble finding any details about the Exception (what type of exception, what the Message or Call Stack is). At the moment, something's wrong but I can't see what. And I'll have no chance of fixing it if I don't know what the problem is.
    Thanks for any help,
    Ed

    I use some code for solving this task (in real project with Delphi 6.0 & Java 1.4.1).
    May be, it will help.
    procedure TJavaInterp.CheckJNIException(Message : string);
    begin
    if JNI_ExceptionCheck(JNIEnv) = JNI_TRUE then
    begin
    JNI_ExceptionDescribe(JNIEnv);
    JNI_ExceptionClear(JNIEnv);
    raise Exception.Create(Message);
    end;
    end;{ TJavaInterp.CheckJNIException }
    procedure TJavaInterp.HandleException(excpt : jthrowable);
    var
    Msg: string;
    ESyntax : Exception;
    CauseName : WideString;
    Tag : OleVariant;
    begin
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsCommonSyntaxError) = JNI_TRUE then
    begin
    ESyntax := Self.BuildSyntaxException(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise ESyntax;
    end;
    Msg := Self.GetMessage(excpt);
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsNPScriptRuntimeException) = JNI_TRUE then
    begin
    CauseName := Self.GetCauseName(excpt);
    Tag := Self.GetTag(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise NPScriptHelper.BuildNPScriptRuntimeException(Msg, CauseName, Tag);
    end;
    if JNI_IsInstanceOf(JNIEnv, excpt, FclsHaltException) = JNI_TRUE then
    begin
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise Exception.Create(Msg);
    end;
    Msg := Self.ToString(excpt);
    JNI_DeleteLocalRef(JNIEnv, excpt);
    raise Exception.Create(Msg);
    end;{ TJavaInterp.HandleException }

  • Possible problem calling java from Windows DLL

    I'm am developing on Windows NT 4.0 using JDK 1.3.1.
    What I want to do is to create a DLL that calls into java using the Invocation APIs.
    I am able to successfully create a JVM inside my DLL and find the java classes that i need. The problem is if one of those java classes happens to perform a JNDI function (e.g. InitialDirContext), my DLL doesn't ever return from a call to that class's method.
    Does anyone have any suggestions?

    Thanks for your reply.
    All my JNI functions return ok with out error/exception. The problem is, the one function never returns so that I can check for errors/exceptions.
    I found a work around for the problem. For some reason if I wrap the JNI code in a C++ class, the call hangs. But if I pull that code outside a C++ class, it works like it is supposed to. Not sure why this would be the problem.
    Thanks again for your reply

  • Calling Java from Delphi

    Can ActiveX bridge used for calling Java from Delphi?

    Also trying to solve this problem, after creating the bean i packaged/registered it successfully, (tested the bean using beanbox, works perfectly) then tried calling it via createoleobject in delphi 7
    (*Code Snip *)
    Var
    v : variant;
    begin
    try
    v := createoleobject(Edit1.text); // my class name ie WorldPort.Bean (also tried WorldPort.Bean.1
    except on e:exception do
    showmessage(e.Message)
    end;
    end;
    (*Code Snip*)
    After this simple code failed i started backtracking , eventually after getting "Access Violation...etc in axbridge.dll" all the time. tried delphi "import activex control" got the same access violation.
    Decided to test the example from http://java.sun.com/j2se/1.4.2/docs/guide/beans/axbridge/developerguide/examples.html........ they both crashed on execution (calc.exe and boundprop.exe).
    After this failed I tested these example classes on another machine, both crashed again.....
    Also tried this experiment in VC++ , after adding the class to the Toolbox , i try to drop it onto a form, once again access violation.**PS**
    ('You will need VC++ and the Microsoft SDK to build the dll, download c++beta for free from microsoft site it you need it')** and a simple cmd file todo the job would look something like this:
    echo - ** Build Java ActiveX Bridge **
    echo Make sure these folders exist in jre--> axbridge\lib and axbridge\bin
    cd\SDK\jre\axbridge\bin
    set path=%path%;C:\MSDN\Bin;C:\VisualC++\lib
    echo path
    javac WorldPort.java
    jar cmf Manifest.txt WorldPort.jar WorldPort.class
    "C:\SDK\bin\packager.exe" -clsid {162193C4-AD5C-4A06-9F88-A737AE9B43AD} -out "C:\SDK\jre\axbridge\bin" WorldPort.jar WorldPort-reg
    *** After running this cmd you will find the dll in bin folder and the jar in lib folder..***
    Must Read:http://java.sun.com/j2se/1.4.2/docs/guide/beans/axbridge/developerguide/index.html
    Hope some of this helps , if you have successfully created / installed/ used a "JavaActiveX" in Delphi , i would really like to try replicate it on my machine..

  • Calling webservices from ABAP via https/ssl with p12 certificates.

    Hi all,
    I have a problem with calling an external webservice via HTTPS.
    I configured my system as indicate in the blog /people/jens.gleichmann/blog/2008/10/31/calling-webservices-from-abap-via-httpsssl-with-pfx-certificates but when I check the RFC connection the result is: ICM_HTTP_SSL_ERROR.
    I check the ICM monitor and this is the result:
    [Thr 11] Thu May 26 16:02:57 2011                                                                               
    [Thr 11] *** ERROR during SecudeSSL_SessionStart() from SSL_connect()==SSL_ERROR_SSL                                           
    [Thr 11]    session uses PSE file "/usr/sap/SV5/DVEBMGS10/sec/SAPSSLHTTPS1.pse"                                                
    [Thr 11] SecudeSSL_SessionStart: SSL_connect() failed                                                                          
      secude_error 536875072 (0x20001040) = "received a fatal SSLv3 handshake failure alert message from the peer"                 
    [Thr 11] >>            Begin of Secude-SSL Errorstack            >>                                                            
    [Thr 11] WARNING in ssl3_read_bytes: (536875072/0x20001040) received a fatal SSLv3 handshake failure alert message from the peer
    WARNING in ssl3_output_cert_chain: (12354/0x3042) No hierarchy certificate in FCPath                                           
    WARNING in reduce_FCPath_by_Issuer: (12354/0x3042) No hierarchy certificate in FCPath                                          
    [Thr 11] <<            End of Secude-SSL Errorstack                                                                            
    [Thr 11]   SSL_get_state() returned 0x000021d0 "SSLv3 read finished A"                                                         
    [Thr 11]   Server's List of trusted CA DNames (from cert-request message):                                                     
    [Thr 11]     #1  " certificate 1
    [Thr 11]     #2  " certificate 2
    [Thr 11]   SSL NI-sock: local=ip  peer=ip2                                                       
    [Thr 11] <<- ERROR: SapSSLSessionStart(sssl_hdl=6000000000652010)==SSSLERR_SSL_CONNECT                                         
    [Thr 11] *** ERROR => IcmConnInitClientSSL: SapSSLSessionStart failed (-57): SSSLERR_SSL_CONNECT [icxxconn_mt.c 2012]
    SAP_ABA     700     0012     SAPKA70012     Componenti validi per tutte le applicazioni
    SAP_BASIS     700     0012     SAPKB70012     Componenti di base SAP
    PI_BASIS     2005_1_700     0012     SAPKIPYJ7C     PI_BASIS 2005_1_700
    ST-PI     2008_1_700     0001     SAPKITLRD1     SAP Solution Tools Plug-In
    SAP_BW     700     0013     SAPKW70013     SAP NetWeaver BI 7.0
    SAP_AP     700     0010     SAPKNA7010     Piatt. d'applicazione SAP
    CCM     200_700     0010     SAPK-27010INCCM     CCM 200_700 : Add-On Supplement
    SRM_PLUS     550     0010     SAPKIBK010     SRM_PLUS per mySAP SRM
    SRM_SERVER     550     0010     SAPKIBKT10     SRM_SERVER
    BI_CONT     703     0001     SAPKIBIIP1     Contenuto Business Intelligence
    ST-A/PI     01L_BCO700     0000          -     Servicetools for other App./Netweaver 04
    What do you think about it?
    Best regards,
    Norberto.

    Don´t forget to set your proxy settings! Be sure that the application server could establish a connection to the external server.
    From the BLog.
    Thr 11 WARNING in ssl3_read_bytes: (536875072/0x20001040) received a fatal SSLv3 handshake failure alert message from the peer
    From the Error.
    Have you looked into the above details?
    Thanks
    SM

  • ResourceBundle throws MissingResourceException when calling Java from C

    All,
    Our code calls Java from C application.
    The C code create JVM using JNI_CreateJavaVM. Due to internal design issues we don't
    create the JVM with a "-classpath" option.
    After creating the JVM, we create a ClassLoader (URLClassLoader), with a URL list as it's classpath.
    The last step in the C code is to load a Java class using the C reference to URLClassLoader.loadClass
    (I will refer to this class as classA), and than call one of it's static methods.
    Please notice that classA is not instantiated, we call a static method.
    At this point we are moving to the Java code...
    In the Java static method we call ResourceBundle.getBundle("resources.messages"),
    the result is ResourceBundle throws MissingResourceException.
    - The JAR hosting "resources/messeges.properties" (refer as jarA) is include in the
    ClassLoader URL paths we used for loading the Java class.
    - Using a debugger we can see that ClassLoader.getSystemClassLoader() don't contain
    jarA in it's URL list.
    - Using the debugger we see that classA.class.getClassLoader() does contain
    jarA in it's URL list.
    After some investigation we see that ResourceBundle.getBundle calles to ResourceBundle.getLoader:
    private static ClassLoader getLoader() {
            Class[] stack = getClassContext();
            /* Magic number 2 identifies our caller's caller */
            Class c = stack[2];
            ClassLoader cl = (c == null) ? null : c.getClassLoader();
            if (cl == null) {
                cl = ClassLoader.getSystemClassLoader();
            return cl;
        } getClassContext() - native method, this can explain the why the above work fine for Windows.
    I suspect the problem raised in the above code. Since I couldn't get a debug
    version of rt.jar for Solaris, I need some help.
    Our environment is Solaris 8, Java 1.5.
    Please note that the same code works fine on WindowsXP with the same Java version!
    Thanks,
    Avi

    I was thinking JVM should the classpath when it is invoked. But obviously it is not and we need to assign the classpath ourselves when invoking from native side. Thanks for pointing that out. For other people's benefit the following is the code piece I for initializing JVM.
    char* str1;
              char* str2;
              char* classpath;
              str1 = "-Djava.class.path=";
              str2 = std::getenv("CLASSPATH");
              classpath = (char*)malloc(strlen(str1) + strlen(str2) + 1);
              strcpy(classpath, str1);
              strcat(classpath, str2);
              if (str2 == NULL)     {
                   printf("CLASSPATH environment variable is not defined.");
                   exit(1);
              m_VmArgs.version = JNI_VERSION_1_4;
              m_options[0].optionString= classpath;
              m_VmArgs.options = m_options;
              m_VmArgs.nOptions = 1;
              m_VmArgs.ignoreUnrecognized = JNI_TRUE;
              JNI_GetDefaultJavaVMInitArgs(&m_VmArgs);
              /* Create the Java VM */
              m_Res = JNI_CreateJavaVM(&m_Jvm, (void**)&m_Env, &m_VmArgs);
              if (m_Res < 0) {
                   printf("Can't create JVM\n");
                   exit(1);
    thanks,
    chancellor

  • Call java from ABAP

    JCo connectivity is used to call RFCs from Java. can i call Java from abap?
    thanks in advance.....
    regards,
    Sundararamaprasad

    Hi Sundar ,
             This link will surely give u an idea about calling java fro ABAP using Jco.
    http://www.thespot4sap.com/Articles/SAP_Netweaver_Java_Connector.asp
    regards,
    aravindh.

  • Problem calling simplebutton from library

    Hi guys,
    I'd like to ask for your assistance. I have a problem calling
    SimpleButton from library. I already checked the Linkage:Export for
    actionscript but still an error appear "Call to a possibly
    undefined method OkBtn". I'm just wondering because this method
    works on my MovieClips except for SimpleButtons. Is there another
    way to call SimpleButtons?
    Here's my code calling MovieClip:
    var mc:MovieClip = new ourProduct();
    and same in calling my SimpleButton:
    var myOkBtn:SimpleButton = new OkBtn();
    please help.
    Thank you very much

    Hi again,
    Since I could not call my SimpleButton inside the library, I
    was thinking of putting my button inside the movieclip and call
    that clip inside my library.
    On my stage, I called
    underConstructionPane() movieclip. This
    underConstructionPane contains
    myOkBtn which previously I wanted to call but as a work
    around, I just put it inside
    underConstructionPane movieclip with instance name of
    okBtn. I added eventHandler on
    okBtn which supposed to call
    showHome() function outside
    underConstructionPane.
    showHome() was declared on the stage or root (I don't know
    the correct term. hehehe
    sorry.) but I don't know how to call that function.
    I tried this:
    var home = new showHome();
    but it won't work.
    Please help me
    Thank you.

  • Call java from sybase trigger

    Is it possible to call java from Sybase trigger ? If so can you please supply example or URL to one ? Alternative solution is to call shell script from sybase trigger (as app is based on Solaris).
    Regards
    Michal

    Thank for your opinion, but what idea is better ?Doing things in the middle tier, where Java lives.
    Ever heard of event-based trading systems?
    pooling a table every 30 sec. ?. I need to implment
    real-time system which process each trade from table
    once it appears there.Sounds like you have it backwards - you're trying to drive Java from the database.
    I think it'd be better to write that event-based system in Java and leave the database just for persistence.
    GigaSpaces and their ilk are being used this way for highly transactional trading systems. Maybe you could see how they're doing it.
    %

  • Advantages and Disadvantages of calling java from PL/SQL

    Hi,
    I have one doubt. What are all the advantages and disadvantages of the calling java from PL/SQL?
    In actual scenario the java program will be in the Application server side. It will do the operation and it will store the result in Data base. But in this case (calling java from PL/SQL), we are loading the java program in the Data base and it is doing the operations.
    I have seen many posts are coming regarding loading jar files into the database. Actually the jar will deploy in to Application server. Is there any difference instead of keeping in the Application server side?
    Then I have read,
    advantages:
    -> java having lot API's. so PL/SQL can use that API's.
    -> if we can not do anything in PL/SQL. we can do it using this mtd(calling java from PL/SQL).
    My questions:
    -> could you explain what are all the things we can not do but we can do using "calling java from PL/SQL" method?
    -> is there any other advantages?
    Disadvantages:
    -> the performance is very slow in calling java from PL/SQL.
    My questions:
    -> Then why others are loading java files and jar files into database?
    -> is there any other disadvantages?
    Could you explain about this one? It will be more helpful to others also…
    Regards,
    kk

    Hi,
    You can read the free first chapter of my book @ http://www.amazon.com/gp/product/1555583296/ (see details then Excerpt)
    Kuassi http://db360.blogspot.com

  • Questions abt. calling Java from C

    I have a java class that contains a method I need to make accessable to C functions. It looks something like this:
    public class ExportName
       private SomeObj theObj;
       public ExportName(SomeObj theObj)
          this.theObj = theObj;
       } //end ExportName
       public String getName()
          return theObj.getName();
       public native String getNameJNI();
    }Using javah I have my ExportName.h, and I'm in the process of writing ExportName.c:
    #include <stdio.h>
    #include <jni.h>
    #include "ExportName.h"
    JNIEXPORT jstring JNICALL Java_ExportName_getNameJNI (JNIEnv *, jobject)
       jclass cls = (*env)->GetObjectClass(env, obj);
       jMethodID mid = (*env)->GetMethodID(env, cls, "getName", "()Ljava/lang/String");
       if (mid == 0)
          return;
       } /* end if */
    }I have 2 questions:
    (1)At some point, I need to actually call the java method using
    (*env)->Call<TYPE>Method(env, obj, mid);
    What type should I use here (CallWhatMethod)?
    (2)Also, I need to create genuine C wrappers for these methods. How do I hand off the jstring returned by this JNI C code to the ANSI C method that calls it? I know that there is a conversion along the lines of:
    const char str = (env)->GetStringUTFChars(env, <<JSTRING HERE>>, 0);
    Can I just put the call to the JNI method where the jstring variable name goes?
    Any help would be appreciated. I have already read the Java tutorial on JNI, so please don't respond just to tell me to go there.
    Thanks!

    If that is the case, then your starting point is not javah, but to investigate the invocation API, after which you will call java methods from C.
    Well, the Invocation API is mostly orthogonal to whether you are calling Java from C or vice versa. The Invocation API is mostly about creating/destroying VMs. You can call Java methods from a flat C application or you can call Java methods from C from within Java native methods.
    If you want to call Java from C, you need to use the methods you're using like GetMethodID, CallXXXMethod, etc...
    In your particular example, if you wanted to call ExportName.getName(), you would use CallObjectMethod. You would cast the result to a jstring, and then use GetStringUTFChars, ReleaseStringUTFChars, etc...
    God bless,
    -Toby Reyelts
    For a solution to all your JNI woes, check out Jace - http://jace.reyelts.com/jace

  • Problem receiving pics from friends via their cell phones

    Is anyone having a problem receiving pictures from anyone via MMS.......I can send them out, but I am unable to receive. I checked my settings, but unable to locate the problem, any help would be great appreciated.

    I am also having a problem with picture messaging. I am on Telus in Canada, but I can receive pictures from a friend with Iphone. But I have another friend who can receive pictures from me but I can't from them (they use a Blackberry). Normal text messaging works fine between us but no picture returns. What gives?

  • How to call a LV.exe from LV via ActiveX?

    Hi all,
    I need some kind of atomic task, e.g. some (short) instructions that cannot be aborted. Calling a DLL, wait some ms, calling it again... And even an Abort via VI server shall not abort this atomic task but finish it.
    I thought about building an LV application and run it via ActiveX.
    Building the app is managed. But running it via ActiveX is still unsolved.
    Have extensively searched for examples for this, but the only source I came up with was
    http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DD6B56A4E034080020E74861&p_node=DZ52051&p_source=external
    This one is about 6 years old and talks about LV 5.1, whereas I use LV 7.1.
    Nevertheless I have performed all steps as described there, e.g. enabling ActiveX, granting privileges, enabled DCOM with dcomcnfg and registering my app. Finally I could open an automation refnum to it. But whatever ActiveX class I choose, there's no way to set a control in my app and to run or call it. Lots of mysterious errors (depending on what class I choosed), amoung them 5012 (exception occored).
    Any newer instruction or another idea on how to get an atomic VI?
    BTW, I am not sure if a DLL would do it, as it runs in the context of LabVIEW. I believe I need this atomic VI in a different context. Right?Message Edited by LuI on 06-17-2005 04:08 PM

    Hi Lul
    I create a small example to run an LV application an run it via ActiveX in LV 7.1.
    To build the application I change:
    VI settings => Run when opened => No
    Application settings => Enable Active X server
    to register the executable I only run it once.
    Hope this helps
    Manuel
    Attachments:
    example.zip ‏45 KB

  • Problems with context in JAXB and ActiveX bridge

    Hello!
    I'm using Java ActiveX Bridge for accesing from Navision to a digital invoice API developed by spanish Industry, Commerce and Tourism Department.
    I successfully executed the invoice creation process from a standalone java application. However, it doesn't work through activex bridge.
    I suspect the problem is probably related to a classloader woe. Here's the first code snippet I used:
      public static void marshal(es.mityc.facturae31.Facturae paramFacturae, String paramString)
        try
          logger.info("Loading context es.mityc.facturae31");
          JAXBContext localJAXBContext = JAXBContext.newInstance("es.mityc.facturae31");
          logger.info("Creating marshaller"); The obtained exception is:
    java.lang.NullPointerException
         at javax.xml.bind.ContextFinder.find(ContextFinder.java:279)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:244)
         at es.mityc.facturae.utils.MarshallerUtil.marshal(MarshallerUtil.java:85)
         at com.mailgrafica.navifacturae.Facturae31.firmar(Facturae31.java:3153)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
         at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.BeanDispatchImpl.invoke(Unknown Source)Then, I changed code to make sure the context creation method receives a classloader which loads classes from appropiate jar file (Facturae-API.jar):
          URL[] urls = { new URL("file:///c:/Archivos de programa/Java/jre6/axbridge/lib/Facturae-API.jar"),
                    new URL("file:///c:/Archivos de programa/Java/jre6/axbridge/lib/lib/jaxb-api.jar"),
                    new URL("file:///c:/Archivos de programa/Java/jre6/axbridge/lib/lib/jaxb-impl.jar"),
                    new URL("file:///c:/Archivos de programa/Java/jre6/axbridge/lib/lib/jsr173_1.0_api.jar")};
          ClassLoader oldcloader = Thread.currentThread().getContextClassLoader();
          URLClassLoader cloader = new URLClassLoader(urls, oldcloader);
          Thread.currentThread().setContextClassLoader(cloader);
          logger.info("Created URLClassloader");
          logger.info("Loading context es.mityc.facturae31");
          JAXBContext localJAXBContext = JAXBContext.newInstance("es.mityc.facturae31", cloader);
          logger.info("Creating marshaller");
          Marshaller localMarshaller = localJAXBContext.createMarshaller();
          FacturaeNamespacePrefixMapper localFacturaeNamespacePrefixMapper = new FacturaeNamespacePrefixMapper();
          localMarshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", localFacturaeNamespacePrefixMapper);
          FileOutputStream localFileOutputStream = new FileOutputStream(paramString + ".xsig");
          logger.info("Starting the marshal process");
          System.out.println("Starting the marshal process");
          localMarshaller.marshal(paramFacturae, localFileOutputStream);  // Exception now is produced here.  Now the exception is:
    javax.xml.bind.JAXBException: class es.mityc.facturae31.Facturae nor any of its super class is known to this context.
         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:556)
         at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:478)
         at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
         at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257)
         at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
         at es.mityc.facturae.utils.MarshallerUtil.marshal(MarshallerUtil.java:92)
         at com.mailgrafica.navifacturae.Facturae31.firmar(Facturae31.java:3153)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
         at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.BeanDispatchImpl.invoke(Unknown Source)Could anybody help me? Thanks in advance.

    According problem 1: this is not normal behavior and you could try first to restart Bridge holding down option key to reset the preferences.
    But if you experience this also on the server I don't know if this solutions works. And according to problem 2, you should open a case on Adobe support using the little contact button top right on this page, not many users (including me) of this forum are using a server or know a lot about of that workflow :-(
    You could try a forum search also on the word server (Search for forum only works when you are on the mainpage with al the post for Bridge for some strange reason...)

  • Calling java from c++

    Hello, i've got this c++ code
    #include "stdafx.h"
    #include "jni.h"
    #pragma comment(lib,"jvm.lib")
    #define MAIN_CLASS "hola"
    int main()
    JNIEnv *env;
    JavaVM *jvm;
    JDK1_1InitArgs vm_args;
    jint res;
    jclass cls;
         jmethodID mainId;
    jstring jstr;
    jobjectArray args;
         jobject obj;
    char classpath[1024];
    JNI_GetDefaultJavaVMInitArgs(&vm_args);
    /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
    vm_args.version = JNI_VERSION_1_4;
    // vm_args.classpath = "C:/Program Files/Java/jdk1.5.0_12/lib";
    JNI_GetDefaultJavaVMInitArgs(&vm_args);
    /* Create the Java VM */
    res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
    if (res < 0) {
    printf("Can't create Java VM\n");
         }else{
              cls = env->FindClass(MAIN_CLASS );
              mainId = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
              env->CallStaticVoidMethod(cls, mainId, 0); /* call main() */
              jmethodID     mid          =     env->GetMethodID(cls, "metodo1", "(I)V");
              env->CallVoidMethod(cls, mid, 10);
         jvm->DestroyJavaVM();
         return 0;
    and this is the java called:
    public class hola {
    public void metodo1 (int n){
    //     s = "Hola mundo";
         System.out.println("Dentro de metodo1");
    // return 33;
    public static void main(String[] args) {
    System.out.println("Hola mundo");
    my problem is:
    i can call main method from c and works ok
    but i'm not able to call "metodo1". i've got an error in
    this line      functions->CallVoidMethodV(this,obj,methodID,args);
    from the jini.h method executed:
    void CallVoidMethod(jobject obj, jmethodID methodID, ...) {
    va_list args;
         va_start(args,methodID);
         functions->CallVoidMethodV(this,obj,methodID,args);
         va_end(args);
    any idea....
    thanks

    [email protected] wrote:
    Long story but we need to call Java code from our C# app (using J# won't work). Any suggestions on the best way to do this?
    Create a java app. Add a comm API.
    Using C# Process to run it as an executable.
    Write C# code to talk to it via the comm API.
    and talk to it over TCP/IP but that strikes me as overkill when everything is on the same machine.Why?

Maybe you are looking for