You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jbExplorer

Trainee

  • "jbExplorer" started this thread

Posts: 111

Date of registration: Mar 18th 2013

  • Send private message

1

Friday, September 6th 2013, 7:46pm

How to use getRunTime().exec()

Hi,

I'm getting an error

java.lang.Exception: CallByName 'waitFor' failed!



, when using the line


pProcess.waitFor()


, in the code below:




Dim sOutput As String
Dim sFileName As String
Dim sFileSize As String
Dim sWildCard As String
Dim sCurrentOutput As String
' Dim pProcess As #java#lang#Runtime 'Produces a compile error, when getRuntime().exec is used.
' Compile error... Type mismatch. Found 'java/lang/Process' but 'java/lang/Runtime' is required!

Dim pProcess As Variant
Dim brReader As #java#io#BufferedReader

Dim sLine As String

pProcess = #Java#lang#Runtime.getRuntime().exec( "cmd /c dir" )
pProcess.waitFor()

brReader = New BufferedReader( New #java#io#InputStreamReader( pProcess.getInputStream() ) )
sLine = brReader.readLine()

Stop
Do While Not (sLine = Null)
frmIDMPrompt.txtOutput.AppendText( sLine + vbCrLf )
sLine = brReader.readLine()
Loop

jbExplorer

Trainee

  • "jbExplorer" started this thread

Posts: 111

Date of registration: Mar 18th 2013

  • Send private message

2

Friday, September 6th 2013, 8:03pm

RE: How to use getRunTime().exec()

If you modify the pProcess declaration, it won't compile at all:

Dim pProcess As Variant = New #java#lang#Runtime

jbExplorer

Trainee

  • "jbExplorer" started this thread

Posts: 111

Date of registration: Mar 18th 2013

  • Send private message

3

Friday, September 6th 2013, 9:26pm

Got it. For anyone who can use this:



Dim pProcess As #java#lang#Process
Dim brReader As #java#io#BufferedReader

Dim sLine As String

pProcess = #java#lang#Runtime.getRuntime().exec( "cmd /c dir" )
pProcess.waitFor()

brReader = New BufferedReader( New #java#io#InputStreamReader( pProcess.getInputStream() ) )
sLine = brReader.readLine()

Do While Not (sLine = Null)
frmIDMPrompt.txtOutput.AppendText( sLine + vbCrLf )
sLine = brReader.readLine()
Loop

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

4

Tuesday, September 10th 2013, 6:39pm

In Jabaco you can additional use the Shell() command:
[ http://www.jabaco.org/board/p3449-how-to…e-in-linux.html ]

Greatings
theuserbl

jbExplorer

Trainee

  • "jbExplorer" started this thread

Posts: 111

Date of registration: Mar 18th 2013

  • Send private message

5

Tuesday, September 10th 2013, 11:34pm

In Jabaco you can additional use the Shell() command:
[ How to open a file in linux? ]

Greatings
theuserbl
Thanks, theuserbl. Can you also redirect standard output to a Text Box, if you use Shell?

Rate this thread
WoltLab Burning Board