?
Solved

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

Posted on 2003-03-13
4
Medium Priority
?
1,274 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:ashish_arp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:KasKooye
ID: 8126257
.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.
0
 
LVL 18

Accepted Solution

by:
deighton earned 80 total points
ID: 8126431
go to MyComputer->View->Options->File Types

then under edit file type you can find the command that is being used to open a java file

for example, on my pc for a .pdf file I have under open

"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe" "%1"


then if in VB I do

Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe c:\download\sp35ug.pdf"

I launch the pdf in a reader.

0
 
LVL 2

Expert Comment

by:uncle_med
ID: 8126531
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
0
 

Author Comment

by:ashish_arp
ID: 8165868
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
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question