Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Java.exe from VBScript

 
Jeff Tibbits
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jeff Tibbits
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.




http://faq.javaranch.com/java/HowToSetTheClasspath
[ January 29, 2008: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic