GnuPG with Java waitFor() method on Windows?

Joseph Bruni jbruni@mac.com
Tue Jul 29 04:35:02 2003


It might be waiting for some input from your program. Add the --batch 
and --no-tty options to make sure that it doesn't prompt you for 
something. Does the secret key have a passphrase? If so, that's what 
it's waiting for.


On Monday, July 28, 2003, at 06:55 PM, Ruke Wang wrote:

> I am trying to use java Runtime.getRuntime().exec() to call gnupg to 
> decrypt
> encrypted file.  However, even though the file is properly decrypted,
> waitFor() never returns.  The problem does not occur while I tried to 
> verify
> a signed data file.  By the way, is Java SDK1.4 Gnupg compatible?
>
> Thanks,
> Ruke Wang
>
> Here is my code, quite simple:
>
> import java.io.*;
>
> public class LicenseXmlTest
> {
> 	public static void main(String[] args)
> 	{
> 			TestXml tester = new TestXml();
> 			tester.Verify("d:\\test\\test.key");
> 	}
> }
>
> class TestXml
> {
> 	private String ExpireDate;
>
> 	private static String gpg_cmd = "c:\\gnupg\\gpg ";
> 	private static String home_dir = "--homedir d:\\test ";
> 	private static String key_ring = "--keyring ppp.asc --secret-keyring
> sss.asc ";
> 	private static String decrypt_para = "--decrypt ";
> 	private static String output_para = "--output ";
> 	private static String license_file = "d:\\test\\test.txt ";
> 	
> 	public TestXml()
> 	{
> 		ExpireDate = new String("01/01/1970");
> 	}
> 	
> 	public boolean Verify(String infile)
> 	{
> 		try
> 		{
> 			String cmd = gpg_cmd + home_dir + key_ring +
> output_para + license_file + decrypt_para + infile;
> 			Process opengpg = Runtime.getRuntime().exec(cmd);
> 			System.out.println(cmd);
> 			
> 			opengpg.waitFor();
> 			
> 			return true;
> 		}
> 		catch(IOException e)
> 		{
> 			System.err.println("Verify() ioexception" +
> e.toString());
> 			return false;
> 		}
> 		catch (InterruptedException e)
> 		{
> 			System.err.println("Verify() interrupt" +
> e.toString());
> 			Thread.currentThread().interrupt();
> 			return false;
> 		}
> 	}
> }
>
> _______________________________________________
> Gnupg-users mailing list
> Gnupg-users@gnupg.org
> http://lists.gnupg.org/mailman/listinfo/gnupg-users
>