Hi,
I want to connect Joram JMS Server with .Net, I wrote a small java program "TestSend.java" , and it uses the APIs as jms.jar, jndi.jar and so on to send messages to the local JMS server with JNDI. Its source code is:
---------------------------------------------------------------------
import javax.jms.*;
import javax.naming.*;
import java.util.Hashtable;
public class TestSend {
Hashtable jndiProps = new Hashtable();
public void sending()throws Exception
{
jndiProps.put("java.naming.factory.initial",
"fr.dyade.aaa.jndi2.client.NamingContextFactory");
jndiProps.put("java.naming.factory.host",
"localhost");
jndiProps.put("java.naming.factory.port",
"16400");
Context ictx = null;
try {
ictx = new InitialContext(jndiProps);
}
catch (NamingException e) {
e.printStackTrace();
System.out.println(e.toString());
}
Queue queue = (Queue) ictx.lookup("queue");
QueueConnectionFactory qcf = (QueueConnectionFactory) ictx.lookup("qcf");
ictx.close();
QueueConnection qc = qcf.createQueueConnection();
QueueSession qs = qc.createQueueSession(true, 0);
QueueSender qsend = qs.createSender(queue);
TextMessage msg = qs.createTextMessage();
int i;
for (i = 0; i < 10; i++) {
msg.setText("Test number " + i);
qsend.send(msg);
}
qs.commit();
System.out.println(i + " messages sent.");
qc.close();
}
}
---------------------------------------------------------------------
This small java program runs well(under MS-DOS too). I tried
to convert this class to dll file as follows:
---------------
javac TestSend.java
jar cf TestSend.jar TestSend.class
jbimp /usestubrefs /t:library TestSend.jar /out:TestSend.dll
Microsoft (R) Java-language bytecode to MSIL converter version 1.1.4322.0
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corp 2000-2002. All rights reserved.
JbImp warning: Using stub type for Class javax.naming.InitialContext
JbImp warning: Using stub type for Class javax.naming.NamingException
JbImp warning: Using stub type for Class javax.naming.Context
JbImp warning: Using stub type for Class javax.jms.Queue
JbImp warning: Using stub type for Class javax.jms.QueueConnectionFactory
JbImp warning: Using stub type for Class javax.jms.QueueConnection
JbImp warning: Using stub type for Class javax.jms.QueueSession
JbImp warning: Using stub type for Class javax.jms.QueueSender
JbImp warning: Using stub type for Class javax.jms.TextMessage
JbImp warning: Using stub type for Class javax.jms.Message
Created TestSend.dll
--------------
Then I got the this dll file and added it to my J# program, but there was a exception when I called the methode of this dll file, this exception is:
----------------
An unhandled exception of type 'java.lang.ClassNotFoundException' occurred in test.dll
Additional information: You cann't use Dummy Type : javax.naming.InitialContext
------------------
Actually I don't know exactly what Jbimp does, so at first I tried to execute the java program under DOS of WinXP so that
I could ensure that all the classpaths were set correctly in the
environment variables, and the java class file could find every
needed jar files , but why couldn't the dll file find them Did I
do something wrong with jbimp (I use "/usestubrefs" because
it dosn't work with other options)
I am a newbie with .Net and I have to use some complex java APIs(services), is there here any easy way to do it
Thanks and greetings,
Le

Problem:convert java class file to dll with Jbimp
Douglas Hodges
- If you use option /usestubrefs, it does the following:
If a class is referenced and not present in the input, the CLASSPATH environment variable is automatically searched for the missing class and the first found location is displayed with the error information. If this option is not specified, conversion stops if any of the referenced classes are not present in the input.
If this option is specified, stub types are emitted into the created assembly for each of the missing classes. This causes the conversion to succeed, but will cause an exception to be thrown when an attempt is made to access a missing class members at run time.
That is why at runtime your application is failing.
For complete information on jbimp usage use the following link http://msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vjsharp/html/vjgrfjavabinaryconverter.asp
- Also, These class files seem to use functionality from versions other than JDK
1.1.4 which is what J# supports.
However, J# also supports some classes in JDK 1.2 also. For complete information on classes supported by J# in Visual Studio 2005, you might want to refer the following-
http://msdn2.microsoft.com/library/67f25kx3(en-us,vs.80).aspx
You might also want to check out the conversion with the Whidbey Beta2 version of J# SDK
available at http://lab.msdn.microsoft.com/express/vjsharp/ This is the
express edition and contains the necessary jbimp utility also.
Thanks,
Varun
LucVK
Hi Le,
I am building a .net application in which I need to call java methods.
I created a JAR file from the CLASS,converted the JAR file to a DLL.
The DLL is referenced in the application,at run-time it is throwing a exception "java.lang.ClassNotFoundException You cann't use Dummy Type : com.crystaldecisions.sdk.framework.CrystalEnterprise".Could some help me to solve this.
Note:-Java program at runtime isn't giving exception.
I used the command D:\SriramJava>jbimp /usestubrefs /t:library BOMigrationJar.jar /out:BOMigration.dll to convert JAR to DLL.
I copied the below after executing jbimp command
D:\SriramJava>jbimp /usestubrefs /t:library BOMigrationJar.jar /out:BOMigration.dll
Microsoft (R) Java-language bytecode to MSIL converter version 2.0.50727.42
for Microsoft (R) .NET Framework version 2.0.50727
Copyright (C) Microsoft Corp 2000-2002. All rights reserved.
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.CrystalEnterprise
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.ISessionMgr
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.IEnterpriseSession
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.occa.security.ILogonTokenMgr
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.occa.infostore.IInfoStore
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngines
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngines$ReportEngineType
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngine
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.exception.SDKException
Created BOMigration.dll
Could you please help me to resolve this.
Regards
Sriram.
sander van vliet
Hi Le,
I am trying to connect to Central Management Server using Java.I have created a sample program.I set class path as
D:\j2sdk1.4.2_14\lib;D:\Program Files\Business Objects\common\3.5\java\lib\rebean.wi.jar;D:\Program Files\Business Objects\common\3.5\java\lib\rebean.jar;D:\Program Files\Business Objects\common\3.5\java\lib\ceplugins.jar;D:\Program Files\Business Objects\common\3.5\java\lib\cesession.jar;D:\Program Files\Business Objects\common\3.5\java\lib\cecore.jar;D:\Program Files\Business Objects\common\3.5\java\lib\celib.jar;D:\Program Files\Business Objects\common\3.5\java\lib\.;.
Source Code Sample.java
import com.crystaldecisions.enterprise.ocaframework.ServiceNames;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.pluginmgr.*;
import com.crystaldecisions.sdk.plugin.*;
import com.crystaldecisions.sdk.plugin.desktop.report.*;
import com.crystaldecisions.sdk.plugin.desktop.user.*;
import com.crystaldecisions.sdk.framework.*;
import com.businessobjects.rebean.wi.LogicalOperator;
import com.crystaldecisions.sdk.occa.infostore.*;
import com.businessobjects.rebean.wi.*;
import java.util.*;
import java.lang.StringBuffer;
import java.io.*;
public class Sample1
{
public static void main(String[] args)
{
System.out.println("After Method Call");
String Juname = "Administrator";
String Jpwd = "";
String Jcms = "hst-pcs4892:6400";
String Jauth = "secEnterprise";
SDKException Jfailure = null;
boolean JloggedIn = true;
IEnterpriseSession JenterpriseSession=null;
// If no session already exists, logon using the specified parameters.
if (JenterpriseSession == null)
{
try
{
/* Attempt logon. Create an Enterprise session
* manager object.
*/
ISessionMgr JsessionMgr = CrystalEnterprise.getSessionMgr();
// Log on to BusinessObjects Enterprise.
JenterpriseSession = JsessionMgr.logon(Juname, Jpwd, Jcms, Jauth);
String JlogonToken = JenterpriseSession.getLogonTokenMgr().getDefaultToken();
}
catch (SDKException error)
{
System.out.println("Exception Occured");
JloggedIn = false;
Jfailure = error;
}
}
//System.out.println(JloggedIn);
}
}
I am getting this error
Exception in thread "main" java.lang.NoClassDefFoundError: com/crystaldecisions/thirdparty/org/omg/CORBA/TRANSIENT
at com.crystaldecisions.enterprise.ocaframework.ServiceMgrFactory.getServiceMgr(Unknown Source)
at com.crystaldecisions.sdk.occa.security.internal.m.<init>(Unknown Source)
at com.crystaldecisions.sdk.occa.security.internal.SecurityFactory.makeSecurityMgr(Unknown Source)
at com.crystaldecisions.sdk.framework.internal.d.<init>(Unknown Source)
at com.crystaldecisions.sdk.framework.internal.CEFactory.makeSessionMgr(Unknown Source)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr(Unknown Source)
at Sample1.main(Sample1.java:46)
Pls help me to resolve this.
Regards,
Sriram.
mendraz
Hi Le,
I created a JSP application using Apache Tomcat 5.0 server.I converted the class file of the JSP into JAR.when i tried to create a dll using jbimp i am getting an error.Is it possible to create a dll this way.
1) i created a metadata.jsp,this created a class, metadata_jsp.class
2) I created a Jar, d:\ Jar cvf Metadata.jar metadata_jsp.class
3) when i tried to create a dll , d:\ jbimp /usestubrefs /t:library MetaData.jar /out:MyMetaData.dll
I am getting the following error.
JbImp warning: Using stub type for Class org.apache.jasper.runtime.HttpJspBase
JbImp warning: Using stub type for Class javax.servlet.jsp.JspFactory
JbImp warning: Using stub type for Class javax.servlet.http.HttpServletResponse
JbImp warning: Using stub type for Class javax.servlet.Servlet
JbImp warning: Using stub type for Class javax.servlet.ServletRequest
JbImp warning: Using stub type for Class javax.servlet.ServletResponse
JbImp warning: Using stub type for Class javax.servlet.jsp.PageContext
JbImp warning: Using stub type for Class javax.servlet.ServletContext
JbImp warning: Using stub type for Class javax.servlet.ServletConfig
JbImp warning: Using stub type for Class javax.servlet.http.HttpSession
JbImp warning: Using stub type for Class javax.servlet.jsp.JspWriter
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.CrystalEnterprise
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.ISessionMgr
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.framework.IEnterpriseSession
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.occa.security.ILogonTokenMgr
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.occa.infostore.IInfoStore
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngines
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngines$ReportEngineType
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportEngine
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.DocumentInstance
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.DataProviders
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.DataProvider
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.Query
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.Reports
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.Report
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.DataSource
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.Recordset
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportStructure
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.TreeNode
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportContainer
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportBody
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.ReportElement
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.TableCell
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.Cell
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.CellContentType
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.PaginationMode
JbImp warning: Using stub type for Class com.businessobjects.rebean.wi.PageNavigation
JbImp warning: Using stub type for Class com.crystaldecisions.sdk.occa.infostore.IInfoObjects
JbImp warning: Using stub type for Class com.businessobjects.sdk.plugin.desktop.universe.IUniverse
JbImp warning: Using stub type for Class javax.servlet.jsp.SkipPageException
JbImp warning: Using stub type for Interface org.apache.jasper.runtime.JspSourceDependent
JbImp warning: Using stub type for Class javax.servlet.ServletException
JbImp warning: Using stub type for Class javax.servlet.http.HttpServletRequest
JbImp error: Failed to generate IL for method org/apache/jsp/metadata_jsp._jspService. Generating stub IL for the method
JbImp error: Failed to create type for class 'org/apache/jsp/metadata_jsp'. Creating stub type
JbImp error: Internal Conversion Error : 'JbImp fatal error: Conversion failed'
Pls help me to resolve this.
Regards,
Sriram
RadhaHsn
thank you very much for your information. But I am still a little
confused about this problem.
My java program "TestSend.class " runs well, why did I get
the problem when I tried to build it in dll file with jbimp Could
jbimp find the needed class files just like what the TestSend.class did
You said:
"..., the CLASSPATH environment variable is automatically searched for the missing class and the first found location is displayed with the error information. If this option is not specified, conversion stops if any of the referenced classes are not present in the input. "
I set the classpath environment variables correctly(so that the java program could find them), I really don't understand why
here the error information is still displayed
I don't think the JMS APIs are supported by J#, is there any possibility to use them in .Net, even if I can't convert the jar files directly in dll files
Once we had updated our Visual Studio .Net 2003 to version 2005, but we got a lot of problem with the new version( many C# programs couldn't be executed any more in 2005),
would there be such problems if I install "Visual J# 2005 Express Edition Beta 2"
I have little experciences for this kind of problems, maybe
I have just asked some stupid questions. But I will greatly appreciate your help if you could give me some suggestions
with details ( it has already taken me several weeks).
Thanks a lot!
Le