![]() |
Ejecutar archivo .JAR desde DElphi
Hola comunidad he estado buscando como ejecutar un archivo .JAR desde delphi, (XE5), y he encontrado varia información al respecto: http://www.clubdelphi.com/foros/showthread.php?t=41916, pero las he probado y ninguna me ha funcionado, actualmente este es el código de pascal que tengo:
Pero pues no me funciona esta no ejecuta el .jar, adicionalmente tengo un .bat con el siguiente comando: java -jar API_WS_SDL_SIMPLE.jar "1" "1" "1" "1018458060" "[email protected]" "CR 78 # 1-03" "2936359" "14" "5" "150" "14" "6" "151" "08-06-2014" "08-06-2014" "C" "G" "JUAN" "14" PAUSE Y este si funciona, ¿Podria alguno de ustedes ayudarme a ejecutar el .jar? |
Juan, utiliza esta rutina para firmar archivos xml utilizando rutina.jar
txtComando.Text:='c:\jdk1.7.0_13\bin\java -jar rutina.jar firma archivos.xml archivo_salida.xml ; txtSalida.Text := ejecutarComando(txtComando.Text); function ejecutarComando (comando : string) : string; var Buffer: array[0..4096] of Char; si: STARTUPINFO; sa: SECURITY_ATTRIBUTES; sd: SECURITY_DESCRIPTOR; pi: PROCESS_INFORMATION; newstdin, newstdout, read_stdout, write_stdin: THandle; exitcod, bread, avail: Cardinal; begin Result:= ''; if IsWinNT then begin InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(@sd, true, nil, false); sa.lpSecurityDescriptor := @sd; end else sa.lpSecurityDescriptor := nil; sa.nLength := sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle := TRUE; if CreatePipe(newstdin, write_stdin, @sa, 0) then begin if CreatePipe(read_stdout, newstdout, @sa, 0) then begin GetStartupInfo(si); with si do begin dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW; wShowWindow := SW_HIDE; hStdOutput := newstdout; hStdError := newstdout; hStdInput := newstdin; end; Fillchar(Buffer, SizeOf(Buffer), 0); GetEnvironmentVariable('COMSPEC', @Buffer, SizeOf(Buffer) - 1); StrCat(@Buffer,PChar(' /c ' + comando)); if CreateProcess(nil, @Buffer, nil, nil, TRUE, CREATE_NEW_CONSOLE, nil, nil, si, pi) then begin repeat PeekNamedPipe(read_stdout, @Buffer, SizeOf(Buffer) - 1, @bread, @avail, nil); if bread > 0 then begin Fillchar(Buffer, SizeOf(Buffer), 0); ReadFile(read_stdout, Buffer, bread, bread, nil); Result:= Result + String(PChar(@Buffer)); end; Application.ProcessMessages; GetExitCodeProcess(pi.hProcess, exitcod); until (exitcod <> STILL_ACTIVE) and (bread = 0); end; CloseHandle(read_stdout); CloseHandle(newstdout); end; CloseHandle(newstdin); CloseHandle(write_stdin); end; end; saludos jgutti |
Recuerda poner los tags al código fuente, ejemplo:
![]() Gracias :) |
Respuesta
Hola jgutti, agradezco tu ayuda, intente probar tu rutina y no me funciono, así que tuve que implementar otra solución, así que aquí se las explico, tuve que colocar un intermediario entre el ejecutable de Pacal y el Jar de Java, en este caso como lo tengo en un equipo con arquitectura Windows, construí un archivo por lotes .BAT, en el código fuente de Pascal coloque la siguiente instrucción:
El código de .BAT es el siguiente: Código:
CD "API_WS_SDL_SIMPLE" |
| La franja horaria es GMT +2. Ahora son las 05:49:26. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi