It's not a secret anymore!
The moose likes Beginning Java and the fly likes Running Java.exe from VBScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running Java.exe from VBScript " Watch "Running Java.exe from VBScript " New topic

Running Java.exe from VBScript

Jeff Tibbits

Joined: Jan 28, 2008
Posts: 2
I have a program that starts via a java command. If I look at the properties for the shortcut, it has�

Target Type: Application
Target Location: bin
Target: "C:\Program Files\CBS\CBPay\javaRt\bin\java.exe" -Derrors com.cbsgame.cbPlus.CBPlus -ms16777216 -mx268435456
Start In: �C:\Program Files\CBS\CBPay�

If I run the application via this shortcut, it runs fine. I need to run it via vbscript. I am using the below syntax�

Set RegObj = WScript.CreateObject("WScript.Shell")
appName = """C:\Program Files\CBS\CBPay\javaRt\bin\java.exe"" -Derrors com.cbsgame.cbPlus.CBPlus -ms16777216 -mx268435456"
MsgBox appName
RegObj.Run appName

When I run it, the command prompt screen flashes and nothing happens. If I change the java.exe to javaw.exe, it gives me �Could not find the main class. Program will exit.� I have tried adding �-cp c:\Program Files\CBS\CBPay� and it still doesn�t work. I tried removing the �Start In� on the shortcut and sure enough, it does the same thing and stops working. Also, if I Start==>Run and paste that command and run it, it does the same thing and flashes the command prompt screen and nothing happens. It's like it just doesn't have a path to something. I have no "Java" experience and beginner VBScript...So any assistance would be greatly appreciated! Thanks!
Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

Run the command from the command line, but in a different folder:
cd \
"C:\Program Files\CBS\CBPay\javaRt\bin\java.exe" -Derrors com.cbsgame.cbPlus.CBPlus -ms16777216 -mx268435456

Unlike javaw.exe, java.exe will print all errors to the console.
[ January 29, 2008: Message edited by: Rob Prime ]

How To Ask Questions How To Answer Questions
Jeff Tibbits

Joined: Jan 28, 2008
Posts: 2
Thank You! I gave that a try and I receive ""Exception in thread "main" java.lang.NoClassDefFoundError: com/cbsgame/cbPlus/CBPlus"

I believe a major part of my problem is that I am majorly JAVA challenged and don't really know what that "com.cbsgame.cbPlus.CBPlus" portion of the java command relates to. I searched for jar file names CBPlus and found one in "c:\program files\CBS\CBPay\client\lib", but don't see how that relates/translates to the ".com.cbsgame..." in the JAVA command?

Thanks again!
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

In the FAQ section for this forum there is a section setting up classpaths.
The classpath is what Java uses to find Java classes.
It can either be set up as an environment variable or passed into the java command as a switch argument.
[ January 29, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Running Java.exe from VBScript
It's not a secret anymore!