VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Do you know that you can call Java classes from Visual Basic ??

by foxsermon (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (10 Votes)

I updated my article, cause for some reasons, Microsoft removed the SDK from its site. So finally I found it in another place (its include below) I did test it and worked it again. So if anyone wants to know how it works, just try it.
Any problem, dont hesitate to contact me.

Rate Do you know that you can call Java classes from Visual Basic ??

Do you know that you can call Java classes from Visual Basic ??


let me guide you through this.
Firts at all, we need a Java class, 

Here you will find an example:


Java Code 


//**************************************************
public class MyTest {

  public int myfunction(int value1, int value2) {

  return value1+value2;

  }

}

//***************************************************



Compile it

i.e. javac MyTest.java

and when you get MyTest.class file, you must register it for this you will need Microsfot SDK for Java
you can download from this link 

http://www.microsoft.com/java/download/dl_sdk40.htm
or
 http://sf.gds.tuwien.ac.at/subcat/pro/webunitproj/

when you have downloaded and installed. 

include it on Path variable enviroment

just do it using Command Ms-DOS


set path=%path%;C:\Program Files\Microsoft SDK for Java 4.0\bin\


(this path could change)


then you must register our MyTest.class file.

you should do it using javareg.exe file from Microsoft SDK for Java


i.e. javareg /register /class:MyTest /progid:MyTest


if everything is well-done then you should see a MessageBox displayed with 

Succesfull register Class message.

Otherwise, you must check the correct spelling on the command line.

Now, the next step, copy the new Java class file that was generated.

MyTest.class

and paste in C:\Winnt\Java\Trustlib\ folder

if you have windows 98, this folder may change.

And the last step, open a New Project on Visual Basic.

And paste this brief code on the Form Load event for example and run it.


 Set x = CreateObject("MyTest")

 MsgBox x.myfunction(1, 1)


Congratulations !!! 


you can use Java Class from Visual Basic. 

Please do not forget to vote for this article. =)

Download this snippet    Add to My Saved Code

Do you know that you can call Java classes from Visual Basic ?? Comments

No comments have been posted about Do you know that you can call Java classes from Visual Basic ??. Why not be the first to post a comment about Do you know that you can call Java classes from Visual Basic ??.

Post your comment

Subject:
Message:
0/1000 characters