java - Call jar file from Powershell and process return value -


i have following scenario:
1. have powershell script foo.ps1
2. within script, want call bar.jar
3. bar.jar runs query against oracle db
4. result of query should passed foo.ps1

the reason why having jar db call because have 32 bit oracle libraries installed, cannot force powershell run in 32 bit mode. tried solutions like
how execute powershell script in 64 bit machine?
although says in console switches 32 bit mode, still exception "attempt load oracle client libraries threw badimageformatexception. problem occur when running in 64 bit mode 32 bit oracle client components installed."

cheers!

i've used 32 bit odac libraries 32 bit powershell console.

[system.reflection.assembly]::loadwithpartialname('oracle.dataaccess') 

after importing above line, can create oracle objects , connect database , run queries.

you can run in 32 bit background job.

start-job -scriptblock $oracle_script_block -runas32 | wait-job | receive-job 

if still want use java code can run this:

$output = & java.exe -jar <oracle jar> write-host "exit code: $lastexitcode" write-host "output: $output" 

as zdan points out, make sure java.exe 32 bit.

& java.exe -version 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -