Page 1 of 1

How to call get value of java console in Livecode

Posted: Fri Oct 14, 2011 11:37 am
by QuangNgo
Hi guys,

I got a java console application and I want to call jar file and get value from console into livecode application.
Could you guys please give me some solutions for this one, It's quite urgent ?

So appreciated.
Regards,
Quang

Re: How to call get value of java console in Livecode

Posted: Fri Oct 14, 2011 3:15 pm
by FourthWorld
For calling console apps see the "shell" function.

Re: How to call get value of java console in Livecode

Posted: Mon Oct 17, 2011 3:39 am
by QuangNgo
Thanks FourthWorld,

I followed to your instruction by using shell to call java console, when I test some window command It works.
However, I try to execute jar file, there are some problem, Hope you can show me what's wrong ?

Here is my code:

Code: Select all

on mouseUp
local volumeSerialNumber
put "C" into pDiskLetter  
put char 1 of pDiskLetter & ":" into pDisk  
set the hideConsoleWindows to true
put shell("dir " & pDisk) into tDirData  
get matchText(tDirData,"Volume Serial Number is (.*)\n",volumeSerialNumber)  
if it is true then
put shell("java -jar Demo.jar ") into tData ============Unable to access jar file Demo.jar
answer tData
else
answer "Disk not found."
end if
  
end mouseUp
when I run "java -jar Demo.jar" on command line it works fine
My jar file is already put into C folder

Could you please give me the solution ?

Best Regards,
Quang

Re: How to call get value of java console in Livecode

Posted: Mon Oct 17, 2011 3:02 pm
by sturgis
Sounds like you put your demo.jar file in the root of the c: drive so it would be at "c:\Demo.jar"

Most likely the folder that your shells are executing from are NOT the root of the c: drive.

If you "put the defaultfolder" it will tell you where your shell will be executed from. If your Demo.jar is not in the same place, the java executable won't be able to find it.

You can solve this in 1 of 2 ways. Either specify the full path to your demo.jar

Code: Select all

put shell("java -jar C:\Demo.jar ") into tData -- assuming i'm correct and your demo.jar is in the root of C:
Otherwise you can just set the defaultfolder to the location of your jar file then execute the shell

Code: Select all

set the defaultfolder to "c:\" -- again, if your jar is NOT in the root of C: specify the correct path here.
put shell("java -jar Demo.jar ") into tData

Re: How to call get value of java console in Livecode

Posted: Tue Oct 18, 2011 5:14 am
by QuangNgo
Dear sturgis,
I resolved this
Thank a lot for helping me :)
Regards,
Quang