How to call get value of java console in Livecode

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
QuangNgo
Posts: 60
Joined: Thu Mar 31, 2011 8:31 am

How to call get value of java console in Livecode

Post by QuangNgo » Fri Oct 14, 2011 11:37 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Fri Oct 14, 2011 3:15 pm

For calling console apps see the "shell" function.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

QuangNgo
Posts: 60
Joined: Thu Mar 31, 2011 8:31 am

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

Post by QuangNgo » Mon Oct 17, 2011 3:39 am

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

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

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

Post by sturgis » Mon Oct 17, 2011 3:02 pm

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

QuangNgo
Posts: 60
Joined: Thu Mar 31, 2011 8:31 am

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

Post by QuangNgo » Tue Oct 18, 2011 5:14 am

Dear sturgis,
I resolved this
Thank a lot for helping me :)
Regards,
Quang

Post Reply