use a scanner in Java

2001-05-18 Thread Luca Aurel



This is more Java than Java - Linux, but I'd 
appreciate your answer:
Does anybody know if there's a way to use a scanner 
in Java ? One of my Java programs is calling a Visual Basic program 
that scans & saves an image, but it's not very fast so I'm trying to 
sinf a 100% Java solution. 
Thanks,
 
Lucas


waitFor after exec never returns

2001-05-18 Thread Ellen Spertus

Sometimes, when I create a process with Runtime.exec, waitFor never
returns, even though I'm clearing the error and output streams. 
Here is my code, with important lines starred:
    static void shexec(String command) throws
InternalErrorException {
String[]
commandArray = {"/bin/sh", "-c", command};
String[]
envArray = {"TERM=vt100"};
Log.logMessage("About
to call exec");
try 
{
   
Log.logMessage("/bin/sh -c " + command);
    Process p =
Runtime.getRuntime().exec(commandArray, envArray);
   
InputStream is = p.getErrorStream();
   
byte cbuf[] = new byte[1024];
   
int len;
   
while ((len = is.read(cbuf, 0, 1024)) != -1) {
if
(len > 0) {
   
String errorMessage = new String(cbuf, 0, len);
   
Log.logMessage("Read " + len + " bytes from
ErrorStream:" + errorMessage);
   
throw new InternalErrorException(errorMessage);
}
   
}
   
Log.logMessage("Done with ErrorStream");
   
is = p.getInputStream();
   
while ((len = is.read(cbuf, 0, 1024)) != -1)
Log.logMessage("Read
" + len + " bytes from InputStream");
   
Log.logMessage("Done with InputStream");
   
p.getOutputStream().close();
   
Log.logMessage("About to call waitFor");
   
p.waitFor();
   
Log.logMessage("Return value is " + p.exitValue());
   
Log.logMessage("Back from waitFor");
} catch (Exception e) {
   
Log.logMessage("Exception occurred: " + e);
   
throw new InternalErrorException(e);
}
    }
My log file reads: 

About to call exec 
/bin/sh -c lynx -dump -force_html
/home/systers/javamlm/archive/94.text-html >
/home/systers/javamlm/archive/94.text-plain 
Done with ErrorStream 
Done with InputStream 
About to call waitFor
I am using: 

java version "1.3.0" 
Java(TM) 2 Runtime Environment, Standard Edition (build
Blackdown-1.3.0-FCS) 
Java HotSpot(TM) Client VM (build Blackdown-1.3.0-FCS, mixed mode)
ps shows the process as being defunct.
This has been frustrating me for a long time.



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Blackdown JDK1.3.1?

2001-05-18 Thread Scott Langley

Hi Blackdown Developers.

Will you be releasing a version of JDK1.3.1 with maybe some of the
deficiences of Sun's just-released version corrected?

In particular:

Support for KDE2:
http://lists.kde.org/?l=kde-core-devel&m=98562599002412&w=2
http://lists.kde.org/?l=kde-core-devel&m=98588662130333&w=2

and avoiding regressions like:
http://java.sun.com/j2se/1.3/relnotes.html#awt

"Bug 4199374 concerns a focus management problem with JWindow objects. In
particular, this bug prevents Component.requestFocus() from giving focus to
components in a JWindow. This bug was fixed in update releases J2SDK
1.2.2_05 and J2SDK 1.3.0_02. However, it is not fixed in J2SDK 1.3.1."

Regards,

Scott Langley
[EMAIL PROTECTED]
http://www.scottlangley.com


__
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Joi Ellis

On Fri, 18 May 2001, Ellen Spertus wrote:

> Sometimes, when I create a process with Runtime.exec, waitFor never
> returns, even though I'm clearing the error and output streams.  Here is
> my code, with important lines starred:
> 
[snip]
> String[] commandArray = {"/bin/sh", "-c", command};
> 
> My log file reads:
>   About to call exec
>   /bin/sh -c lynx -dump -force_html
>   /home/systers/javamlm/archive/94.text-html >
>   /home/systers/javamlm/archive/94.text-plain
>   Done with ErrorStream
>   Done with InputStream
>   About to call waitFor

When I invoke lynx the say way the code does, lynx goes into full-screen
mode. It isn't writing to stdout via the shell's redirect, it' using
ncurses to manipulate my screen.

When I invoke lynx without the shell, it writes to stdout as expected.

Lynx isn't a shell script, you can invoke it directly in the exec() call.

-- 
Joi EllisSoftware Engineer
Aravox Technologies  [EMAIL PROTECTED], [EMAIL PROTECTED]

No matter what we think of Linux versus FreeBSD, etc., the one thing I
really like about Linux is that it has Microsoft worried.  Anything
that kicks a monopoly in the pants has got to be good for something.
   - Chris Johnson


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Ellen Spertus

Thanks for the reply.

>Lynx isn't a shell script, you can invoke it directly in the exec() call.

The reason I don't invoke lynx directly is because I am redirecting its 
output to a file, which of course requires a shell.  I think that was 
obscured by some bad line breaks in my original message.  Let's see if this 
is any clearer:

/bin/sh -c lynx -dump -force_html 94.text-html > 94.text-plain

Ellen


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Joi Ellis

On Fri, 18 May 2001, Ellen Spertus wrote:

> Thanks for the reply.
> 
> >Lynx isn't a shell script, you can invoke it directly in the exec() call.
> 
> The reason I don't invoke lynx directly is because I am redirecting its 
> output to a file, which of course requires a shell.  I think that was 
> obscured by some bad line breaks in my original message.  Let's see if this 
> is any clearer:
> 
> /bin/sh -c lynx -dump -force_html 94.text-html > 94.text-plain
> 

Yes, I noticed the redirection.  Have you actually LOOKED at 94.text-plain
when you invoke this command string manually?  Lynx is going into ncurses
mode because it's confused.

  lynx -dump -force_html 94.text-html > 94.text-plain

does exactly what you want.

  /bin/sh -c lynx -dump -force_html 94.text-html > 94.text-plain

does not.
-- 
Joi EllisSoftware Engineer
Aravox Technologies  [EMAIL PROTECTED], [EMAIL PROTECTED]

No matter what we think of Linux versus FreeBSD, etc., the one thing I
really like about Linux is that it has Microsoft worried.  Anything
that kicks a monopoly in the pants has got to be good for something.
   - Chris Johnson


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Ellen Spertus

At 03:31 PM 5/18/2001 -0500, you wrote:
>Yes, I noticed the redirection.  Have you actually LOOKED at 94.text-plain
>when you invoke this command string manually?

It generates the right output when I can lynx directly but not when I pass 
it through a shell.  I hadn't realized that lynx would behave differently 
depending how it was invoked, as long as environment variables were set 
properly.  Thanks for pointing that out.

>   lynx -dump -force_html 94.text-html > 94.text-plain
>
>does exactly what you want.

Yes, but I can't give that as an argument to Runtime.exec, because it 
includes redirection.  Do you know how to get lynx to do what I want 
(convert a html file into text)?

Ellen Spertus


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Ellen Spertus

At 09:57 PM 5/18/2001 -0500, Joi Ellis wrote:
>Lynx is writing the rendered text to stdout, which you're reading and
>throwing away.  Why not read it and write it to the file yourself?

I thought doing it with redirection would be simpler, but apparently 
not.  I rewrote it so my program grabs the lynx output directly, and all 
works.  I still get a hang on p.waitFor, so I replaced it with p.destroy 
(after I've read the strings).  I'd still like to know why waitFor isn't 
working, but I'm happy my program is running.

Thanks for your assistance.

Ellen


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: waitFor after exec never returns

2001-05-18 Thread Nathan Meyers

Ellen Spertus wrote:

> At 09:57 PM 5/18/2001 -0500, Joi Ellis wrote:
> >Lynx is writing the rendered text to stdout, which you're reading and
> >throwing away.  Why not read it and write it to the file yourself?
>
> I thought doing it with redirection would be simpler, but apparently
> not.  I rewrote it so my program grabs the lynx output directly, and all
> works.  I still get a hang on p.waitFor, so I replaced it with p.destroy
> (after I've read the strings).  I'd still like to know why waitFor isn't
> working, but I'm happy my program is running.

Lynx is probably sitting there waiting for input. Closing the stream to its
stdin (Process.getOutputStream().close()) might help it decide to
terminate.

Nathan


>
>
> Thanks for your assistance.
>
> Ellen
>
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]