Link to home
Start Free TrialLog in
Avatar of ashish_arp
ashish_arp

asked on

problems with "shell" command, not running ".jar" files

hi
 why the sheel command is not able to execute
the ".jar" files like ".exe" files even though they are
also exes but in terms of Java. What i want is, if user pushes
certain button on the form then a file,"abc.jar", should be executed.
Is there another way of doing it??

Thanx in advance
Ashish
Avatar of KasKooye
KasKooye

.jar files are NOT like .exe file to Windows's point of view ! .jar file can only be excuted via Java's VM.

So, if you want to shell a .jar file, try instead this kind of command:

shell "java myProg.jar"

I don't have any longer Sun's Java SDK on my machine, as far as i remember, but this should work.

You can find more options concerning java'c command line arguments into Sun's documentation.

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of deighton
deighton
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is a great alternative for you. Just give it a path to your .exe or any other file that is associated with an application and it'll run it for you:
'
' create a new VB project
' Copy+Paste on a module
'
Private Declare Function ShellExecute _
   Lib "shell32.dll" Alias _
   "ShellExecuteA" (ByVal _
   hWnd As Long, ByVal lpOperation As _
   String, ByVal lpFile As String, _
   ByVal lpParameters As String, _
   ByVal lpDirectory As String, _
   ByVal nShowCmd As Long) As Long


'
' Copy+Paste into same module
'
Sub RunApp(frm As Form, strXLS As _
   String, intWindowStyle As Integer)

   Dim lngSuccess As Long

   'launch the default browser
   lngSuccess = ShellExecute( _
      frm.hWnd, "Open", _
      strXLS, 0&, 0&, intWindowStyle)

End Sub

'
'Create a button on a form and then copy+paste
'
Private Sub cmdRunApp_Click()
    Dim sPath As String
   
    sPath = InputBox("Enter path")
   
    RunApp Me, sPath, 1
   
End Sub
Avatar of ashish_arp

ASKER

hi deighton
 one more problem with shell. I'm running the shell function for compiling the java file as

shell "c:\jdk1.3.1_04\bin\javac.exe abc.java"

the function is not compiling the java file and not giving any error also. what must be the problem??

Ashish