Running Java Class Within VB.NET

I'm not very familar with Java and have a need to run a class passing parameters from within Visual Basic.NET 2010.

The class that needs to be run is "resources.schedulerjobs.AutoPrescriptionMonitorJob". A few of the parmeters that need to be passed are things like BEGINDATE. ENDDATE and XMLPATH.

Is there a way to do this?
vbplayerAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:


You can run java in the same way as any external command:
http://www.devx.com/dotnet/Article/7914

using the command

java resources.schedulerjobs.AutoPrescriptionMonitorJob  01-06-2012 01-07-2012 c:\path_to_file

witrh the she'll or start process command

0
 
for_yanCommented:
You need to make sure that java is installed on your machine and then either to be sure that
the CLASSPATH vvariable is pointing to your classses or specify
-cp ....

and paths to all your lcasses and jars afte -cp on the command likne
which you put on your lain

-cp ...

should conmme before your class which you want to execute
0
 
vbplayerAuthor Commented:
Ok. I found the CLASSPATH that JAVA would be using, see below. The next question is about the parameters. The java program is expecting named parameters in no special order. example: BEGINDATE=01/01/2011, ENDDATE=01/31/2011, XMLPATH=C:\SOMPLACE. In the example you gave me above you just supplied the parameter data. Would I need to actually code it like 'BEGINDATE=01/01/2011' to pass the whole parameter to JAVA?

CLASSPATH: medispan.wkconfig.xml;medispan.dib.wkconfig.xml;medispan.wkconfig.x
sd;medispan.dib.wkconfig.xsd;;;d:\jdk1.5.0_17\/lib/tools.jar;;d:\jdk1.5.0_17\\li
b\tools.jar;d:\jboss401_MSSQL\bin\\run.jar;d:\sqljdbc3.0\sqljdbc_30.jar;d:\advan
cenet\lib\jasperreports-0.6.6.jar;;d:\advancenet\lib\itext-1.3.6.jar;;
.
0
 
käµfm³d 👽Commented:
Use the Process class to launch the Java executable, and pass that executable the appropriate parameters:

System.Diagnostics.Process.Start("java.exe", "resources.schedulerjobs.AutoPrescriptionMonitorJob BEGINDATE ENDDATE XMLPATH")

Open in new window

0
 
for_yanCommented:
If java is reading the whole line BEGINDATE=01/01/2011 just put it this way on the command line
If there were embedded spaces you would need the quotes around parameter, but with equal sign it should be OK

I suggest that you first open cmd window and try to execute your java code from the cmd command line - then
use the way itworks to provide the line in the VB.NET code
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.