Page 1 of 1
2 Questions about RunProgram
Posted: Wed Oct 04, 2006 4:36 pm
by porfirio
Hi all
The first question is:
Why this code gives right output
Code: Select all
OpenConsole()
PrintN("Running Java")
JavaP = RunProgram("java", "-version", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
While ProgramRunning(JavaP)
PrintN(ReadProgramString(JavaP))
Wend
PrintN("Exitcode: " + Str(ProgramExitCode(JavaP)))
Else
PrintN("not a program")
EndIf
Input()
CloseConsole()
and this one dont:
Code: Select all
Debug "Running Java"
JavaP = RunProgram("java", "-version", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
While ProgramRunning(JavaP)
Debug ReadProgramString(JavaP)
Wend
Debug "Exitcode: " + Str(ProgramExitCode(JavaP))
Else
Debug "not a program"
EndIf
And the second question is:
How to not show java process or atleast, when myprocess is killed java is killed too?
As you may notice i am doing a small Java runner.
There's tones of them but i want to do one for my own use, with my own options and i want to be able to compile\run it on Linux\Mac\Windows
I want that if user is runing on windows ( alot noob's ), they can just kill the program in the TaskManager, so hiding the process is just need for windows, on mac\linux i will just run Java
If someone can help me i appreciate

Re: 2 Questions about RunProgram
Posted: Wed Oct 04, 2006 5:34 pm
by Trond
porfirio wrote:Hi all
The first question is:
Why this code gives right output
and this one dont:
Did you turn on the debugger and read the manual description of Debug?
Re: 2 Questions about RunProgram
Posted: Wed Oct 04, 2006 6:58 pm
by porfirio
Trond wrote:porfirio wrote:Hi all
The first question is:
Why this code gives right output
and this one dont:
Did you turn on the debugger and read the manual description of Debug?
Yeah
either i get
Exitcode: 0
Posted: Wed Oct 04, 2006 8:26 pm
by Trond
You do realize that when you create an executable the debugger is always disabled?
Posted: Wed Oct 04, 2006 8:47 pm
by dracflamloc
it is? I thought there was an embedded debugger...
Posted: Wed Oct 04, 2006 8:50 pm
by Trond
Yes, but when you use the create executable menu item from the IDE the debugger is always disabled.
Posted: Wed Oct 04, 2006 9:31 pm
by Character
this way I get an Exitcode of 1
Code: Select all
Debug "Running Java"
JavaP = RunProgram("java", "-showversion", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
While ProgramRunning(JavaP)
Debug ReadProgramString(JavaP)
Wend
Debug "Exitcode: " + Str(ProgramExitCode(JavaP))
Else
Debug "not a program"
EndIf
now without the helptext crap (displayed on my machine instead of the 'version text' when called through a console..)
Code: Select all
Debug "Running Java"
JavaP = RunProgram("java", "-showversion>dump.txt", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
While ProgramRunning(JavaP)
Debug ReadProgramString(JavaP)
Wend
Debug "Exitcode: " + Str(ProgramExitCode(JavaP))
Else
Debug "not a program"
EndIf
all works in a console() but when using the debugger the java thing is already closed for ages when you start purebasing with it
when used '-showversion' the java thing halts execution but only displays the correct version in a console again, not in the debugger....
?
(I'm lost... )
Posted: Thu Oct 05, 2006 9:47 am
by porfirio
If i run java with no argument, it works and display all the help thing on the debugger
If i put any java file to be runned or a jar or something, it shows the output too
It just dont show the output with -version parameter lol
Very wheird...
Edit:
either :
Code: Select all
Debug "Running Java"
JavaP = RunProgram("cmd", "/r java -version", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
While ProgramRunning(JavaP)
Debug ReadProgramString(JavaP)
Wend
Debug "Exitcode: " + Str(ProgramExitCode(JavaP))
Else
Debug "not a program"
EndIf
Dont give the output too again if i dont put -version it displays java help
Edit again:
Theres something wrong with java.exe lol
java -showversion>out.txt
Get all java help shit on the txt and the version printed on the window!!
Oh god looks like i have to give up :S
Posted: Thu Oct 05, 2006 11:20 am
by porfirio
Just found a quick solution for get the jre version
Created a small class file that will be included on the exe using this code
javac Test.java
Code: Select all
public class Test{
public static void main(String[] args){
System.out.println(System.getProperty("java.vm.version"));
}
}
then i have this code on my app
Code: Select all
Procedure TestJava(v.s)
JavaP = RunProgram("java", "Test", "",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If IsProgram(JavaP)
res.s=ReadProgramString(JavaP)
res=Left(res,5)
If Val(StringField(res,1,"."))>=Val(StringField(v,1,"."))
If Val(StringField(res,2,"."))>=Val(StringField(v,2,"."))
If Val(StringField(res,3,"."))>=Val(StringField(v,3,"."))
ProcedureReturn #True
EndIf
EndIf
EndIf
ProcedureReturn #False
Else
ProcedureReturn #False
EndIf
ProcedureReturn #False
EndProcedure
If TestJava("1.6.0")
MessageRequester("Java Test","You have a good java version")
Else
Select MessageRequester("Java Tester", "You dont have Java, or your java Version is outdated" + Chr(10) + "Want to go to Java Website to ge the lastest one?", #MB_YESNO|#MB_ICONQUESTION)
Case #IDYES
RunProgram("http://java.com/")
EndSelect
EndIf
Of course that this will be more worked
Thanks in the same way guy's
