comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* ComponentOrientation Class - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b601af764afa6138
* Redirect stdin using "<" in process started w/ Runtime.exec()? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/774e28df351c13
* Why would file reading stop at 1124 bytes with this code? - 5 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f79ea47a0b0aea21
* runtime.getRuntim().exec(somecmd) problem with linux - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0
* Performance of null tests? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1febd5672a2f269
* Apache Axis and JDK1.5 - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/274cfa6bf37ead9b
* Building an Exception Layer - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a8359d1a0e5422fb
* How can I change the location of the Web Start cache? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4aabb51e96392879
* Implementing Legacy Byte Packed Message Interfaces - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a17f0bc392a7f7
* Looking for a jar manager in java. - 1 messages, 0 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21cca5a7232d050f
* Tomcat responce time 10-200 seconds once in a while - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eff0206fed26be06
* Good Annotation Intro - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6586a2e918c9a5b8
* .getRuntime().exec() - with long command - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/642cef59562edc6e
* slow network image transfers - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fa5c2246b272494
* Is it possible to set a block of code as non-JIT area? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/efa6df384a75654c
* Parsing a string into a proper Java Date - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fa1b8c1f74c2e37
* Thread-question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
* What is the best way to restart a thread? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a59e302ccfd155f9
* Rational Rose - reverse engineering - no attributes - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/609ab2a87ee5f47b
* File transfer to FTP site - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9647b579b1a148
  
==========================================================================
TOPIC: ComponentOrientation Class
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b601af764afa6138
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 8:32 am
From: "Programmiamo.it" <[EMAIL PROTECTED]> 

Hi,
how should be used this class?
Thanks.

Giovanni






==========================================================================
TOPIC: Redirect stdin using "<" in process started w/ Runtime.exec()?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/774e28df351c13
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 8:33 am
From: Lothar Kimmeringer <[EMAIL PROTECTED]> 

On 5 Nov 2004 07:27:39 -0800, Paul  Smith wrote:

> Process process = Runtime.getRuntime().exec("c:\mysql\bin\mysql.exe
> --database=bob < c:\file.sql"

That can't compile, you have to escape the backslashes.

> 
> but I get a usage error returned, even though running the same command
> from a command prompt is fine.

Because it's the shell's responsibility of interpreting "<" as
to read something from a file and send it to the application's
STDIN.

> The problem appears to surround the redirection of standard input
> (i've tried putting a backslash in front of it).

see above

> QUESTION 1 -- Is this not possible using Runtime.exec()?

Of course it's possible, the only problem (despite yours) is
the different behavior of JVM on different OS, e.g. which
environment-variables are passed to the process and others.

> A workaround I have thought of is to pass the name of the file
> containing the sql to my Java program, read it in and pass it to the
> input stream of the external process. However, my application hangs
> when I do this.

If it is the code below, you fill find the answer there.

> QUESTION 2 -- Are there any other alternatives to the workaround
> below?

You can connect the database via JDBC and perform the statements
directly. That would make error-handling and working with the
results of e.g. selects much more convenient. AFAIR there is
a SQL-statement as well for reading in SQL-statements from a
file. That way you can come around everything concerning
the handling of external processes.

> QUESTION 3 -- Why does the code below cause my Java program to hang?
> I've seen it mentioned that the handling of the external process'
> input should be on a different thread. Why is that?
> 
> The workaround code is:
> try
> {
>     OutputStream outputstream = process.getOutputStream();
>     OutputStreamWriter outputstreamwriter = new
> OutputStreamWriter(outputstream);
>     BufferedWriter bufferedwriter = new
> BufferedWriter(outputstreamwriter);
> 
>     BufferedReader br = new BufferedReader(new FileReader(fileName));
>     String s = br.readLine();
>     while (s != null)
>     {
>         bufferedwriter.write(s);
>         s = br.readLine();
>     }
>     bufferedwriter.flush();
> }
> catch (FileNotFoundException fnfe)
> {
>     fnfe.printStackTrace();
> }

You're not reading the output the process produces (not STDOUT
nor STDERR). The buffer for the application for writing to
STDOUT is limited. So if the application write something to
STDOUT and the buffer is already full, the write will block
until the buffer can accept more data again.

Because you're not reading the two input-streams, MYSQL automatically
will block, because the first thing happening is giving out help-
information leading to the fillup of mentioned buffer. If you want
to use process.waitFor, the reading of the two input-streams must
happen within Threads. The latter should answer question 3 as well.


Regards, Lothar
-- 
Lothar Kimmeringer                E-Mail: [EMAIL PROTECTED]
               PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                 questions!




==========================================================================
TOPIC: Why would file reading stop at 1124 bytes with this code?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f79ea47a0b0aea21
==========================================================================

== 1 of 5 ==
Date:   Fri,   Nov 5 2004 8:37 am
From: "Mickey Segal" <[EMAIL PROTECTED]> 

"Carl Howells" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Bad!  Don't use available for *anything*...  It's fundamentally broken. 
> It's certainly the cause of your problem.  Just use the return value from 
> read().  If it's negative, you've reached the end of the file.

I got rid of the available() method and the problem remains.  The new source 
code is below.  I also tried increasing the byte array size from 1024 to 
8196 and this did not fix the problem or change the number of bytes that 
were read (1124).  Getting rid of the fNow.delete() method did not get rid 
of the problem either.

Any other hypotheses as to the cause of the problem?

New source code:

final synchronized String read_delete(String fullPathAndFileString)
{
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    String reportString = "";
    try
    {
        File fNow = new File(fullPathAndFileString);
        fis = new FileInputStream(fNow);
        bis = new BufferedInputStream(fis);
        byte[] b = new byte[8192];
        int length;
        while ((length = bis.read(b)) > 0) reportString += new String(b, 0, 
length);
        fNow.delete();
    }
    catch (Exception e)   {}
    finally
    {
        try
        {
            if (bis != null) bis.close();
            if (fis != null) fis.close();
        }
        catch (Exception e) {}
    }
    return(reportString);
} 





== 2 of 5 ==
Date:   Fri,   Nov 5 2004 10:41 am
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Mickey Segal wrote:

> I got rid of the available() method and the problem remains.  The new source 
> code is below.  I also tried increasing the byte array size from 1024 to 
> 8196 and this did not fix the problem or change the number of bytes that 
> were read (1124).  Getting rid of the fNow.delete() method did not get rid 
> of the problem either.

Does the problem manifest consistently on specific files, or are there 
files for which it sometimes works and sometimes doesn't?

> Any other hypotheses as to the cause of the problem?

Have you considered actually displaying or logging the exceptions you 
may be catching?  That might be very revealing, and it would certainly 
be a better general practice.  Also, it would be better form to close 
your input stream before deleting the underlying file.  As others have 
written, you only need to close the outermost stream.

> New source code:
> 
> final synchronized String read_delete(String fullPathAndFileString)
> {
>     FileInputStream fis = null;
>     BufferedInputStream bis = null;
>     String reportString = "";
>     try
>     {
>         File fNow = new File(fullPathAndFileString);
>         fis = new FileInputStream(fNow);
>         bis = new BufferedInputStream(fis);
>         byte[] b = new byte[8192];
>         int length;
>         while ((length = bis.read(b)) > 0) reportString += new String(b, 0, 
> length);

If your system's default character encoding is a multi-byte encoding 
then this may crash from time when a partial read from the file ends in 
the middle of the sequence of bytes of one encoded character.  UTF-8 is 
a reasonably common default, so that's not so unlikely.  If your file 
contains only character data then you should be using a suitably 
configured Reader instead of an InputStream; otherwise you shouldn't be 
trying to convert the data to String form at all.

>         fNow.delete();
>     }
>     catch (Exception e)   {}
>     finally
>     {
>         try
>         {
>             if (bis != null) bis.close();
>             if (fis != null) fis.close();
>         }
>         catch (Exception e) {}
>     }
>     return(reportString);
> } 

Are you sure you're actually using the revised code?  I suspect that 
most here have had the occasional sheepish "Doh!" moment when we realize 
that the reason our debugging isn't going anywhere is that we are still 
running the original code instead of the debugged.  It has happened to 
me, at least.


John Bollinger
[EMAIL PROTECTED]



== 3 of 5 ==
Date:   Fri,   Nov 5 2004 11:23 am
From: "Mickey Segal" <[EMAIL PROTECTED]> 

"John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Does the problem manifest consistently on specific files, or are there 
> files for which it sometimes works and sometimes doesn't?

When the file is about 4000 bytes the truncation occurs almost always.  The 
truncation seems much less frequent for files of 2000 bytes.

> Have you considered actually displaying or logging the exceptions you may 
> be catching?  That might be very revealing, and it would certainly be a 
> better general practice.  Also, it would be better form to close your 
> input stream before deleting the underlying file.  As others have written, 
> you only need to close the outermost stream.

I had full Exception code in the test version that I ran in a local applet 
and never got any Exceptions.  Of course that could be different running as 
a servlet, but it seemed unlikely that the servlet was exiting with an 
Exception before file reading was complete since execution proceeds on after 
file reading to the next step of file deletion.  But something is going 
wrong so maybe I should test more explicitly.

I'll try moving File.delete to after stream closing, but since the problem 
occurs with File.delete commented out it does not seem to be the problem.

Which stream counts as the "outermost" stream?  FileInputStream or 
BufferedInputStream?

> If your system's default character encoding is a multi-byte encoding then 
> this may crash from time when a partial read from the file ends in the 
> middle of the sequence of bytes of one encoded character.  UTF-8 is a 
> reasonably common default, so that's not so unlikely.  If your file 
> contains only character data then you should be using a suitably 
> configured Reader instead of an InputStream; otherwise you shouldn't be 
> trying to convert the data to String form at all.

The files consist entirely of Strings generated by a Java applet and written 
on the server using the servlet method for which code is listed below.  I 
have verified that the files written are complete.  I don't remember why the 
writing method used non-analagous classes to those used in the 
reading/deleting method.  Would this lead to different String encoding?

> Are you sure you're actually using the revised code?  I suspect that most 
> here have had the occasional sheepish "Doh!" moment when we realize that 
> the reason our debugging isn't going anywhere is that we are still running 
> the original code instead of the debugged.  It has happened to me, at 
> least.

This thought occurred to me part way through testing but I satisfied myself 
this was not the problem for the following reason: when I modified the 
servlet code to remove file deletion, the file was not deleted.

Source code for writing method:

final synchronized String write(String fullPathAndFileString, String 
actionString, String dataString)
{
    String reportString = "";
    FileWriter fileWriter = null;
    PrintWriter printWriter = null;
    try
    {
        fileWriter = new FileWriter(fullPathAndFileString, 
actionString.equals("append"));
        printWriter = new PrintWriter(fileWriter);
        printWriter.println(dataString);
        reportString = "OK";
     }
     catch (IOException e)
    {
        reportString = "error";
    }
    finally
    {
        try
        {
            if (printWriter != null) printWriter.close();
            if (fileWriter != null) fileWriter.close();
        }
        catch (IOException ignored) {}
    }
    return(reportString);
} 





== 4 of 5 ==
Date:   Fri,   Nov 5 2004 12:55 pm
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

Mickey Segal wrote:

> "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>Does the problem manifest consistently on specific files, or are there 
>>files for which it sometimes works and sometimes doesn't?
> 
> 
> When the file is about 4000 bytes the truncation occurs almost always.  The 
> truncation seems much less frequent for files of 2000 bytes.
> 
> 
>>Have you considered actually displaying or logging the exceptions you may 
>>be catching?  That might be very revealing, and it would certainly be a 
>>better general practice.  Also, it would be better form to close your 
>>input stream before deleting the underlying file.  As others have written, 
>>you only need to close the outermost stream.
> 
> 
> I had full Exception code in the test version that I ran in a local applet 
> and never got any Exceptions.  Of course that could be different running as 
> a servlet, but it seemed unlikely that the servlet was exiting with an 
> Exception before file reading was complete since execution proceeds on after 
> file reading to the next step of file deletion.  But something is going 
> wrong so maybe I should test more explicitly.

You should never catch general Exception and ignore it.  If you want to 
catch and ignore more specific exceptions then that may be OK, but you 
should put a comment in the catch block that explains why you can safely 
ignore the exception.

> I'll try moving File.delete to after stream closing, but since the problem 
> occurs with File.delete commented out it does not seem to be the problem.

No, it probably isn't causing your problem, but do observe good form all 
the same.  Doing so habitually will help you avoid potential problems 
you may not even have been aware of.

> Which stream counts as the "outermost" stream?  FileInputStream or 
> BufferedInputStream?

The BufferedInputStream, because you passed the FileInputStream to its 
constructor.  You need not even retain a reference to the 
FileInputStream anywhere in your own code, and you absolutely shouldn't 
manipulate it while the BufferedInputStream is still in use.  (And 
probably not afterward, either.)

>>If your system's default character encoding is a multi-byte encoding then 
>>this may crash from time when a partial read from the file ends in the 
>>middle of the sequence of bytes of one encoded character.  UTF-8 is a 
>>reasonably common default, so that's not so unlikely.  If your file 
>>contains only character data then you should be using a suitably 
>>configured Reader instead of an InputStream; otherwise you shouldn't be 
>>trying to convert the data to String form at all.
> 
> 
> The files consist entirely of Strings generated by a Java applet and written 
> on the server using the servlet method for which code is listed below.  I 
> have verified that the files written are complete.  I don't remember why the 
> writing method used non-analagous classes to those used in the 
> reading/deleting method.  Would this lead to different String encoding?

If the files are written by other code running in the same VM instance, 
or by code running in a different instance of the same VM on the same 
machine, then there should not be an encoding difference.  That does not 
ensure that the encoding is suitable for the data, but I doubt whether 
your problem runs along those lines.

Here's a thought, though: is the same file written and then read and 
deleted within the scope of processing one request, or are the write and 
the read / delete split between two different requests?  If in two 
different requests then could they be in flight concurrently?  That 
could very easily explain how the files are [appearing to be] truncated. 
  The file size trend you're seeing could be related to an I/O buffer size.

> Source code for writing method:
> 
> final synchronized String write(String fullPathAndFileString, String 
> actionString, String dataString)
> {
>     String reportString = "";
>     FileWriter fileWriter = null;
>     PrintWriter printWriter = null;
>     try
>     {
>         fileWriter = new FileWriter(fullPathAndFileString, 
> actionString.equals("append"));

FileWriter is a broken class.  It automatically uses the system's 
default charset, with no option to configure a different one.  If there 
is any reason at all to care about the charset (and there almost always 
is at least _some_ reason) then you should instead use a suitably 
configured OutputStreamWriter wrapped around a FileOutputStream.  You 
can wrap that in a PrintWriter if you like.

>         printWriter = new PrintWriter(fileWriter);
>         printWriter.println(dataString);
>         reportString = "OK";
>      }
>      catch (IOException e)
>     {
>         reportString = "error";
>     }

[...]

John Bollinger
[EMAIL PROTECTED]



== 5 of 5 ==
Date:   Fri,   Nov 5 2004 1:07 pm
From: "Mickey Segal" <[EMAIL PROTECTED]> 

"John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Here's a thought, though: is the same file written and then read and 
> deleted within the scope of processing one request, or are the write and 
> the read / delete split between two different requests?  If in two 
> different requests then could they be in flight concurrently?  That could 
> very easily explain how the files are [appearing to be] truncated. The 
> file size trend you're seeing could be related to an I/O buffer size.

The servlet write is called by one user and the servlet read/delete is 
called by another user, each using Java applets, so there is no concurrency 
issue of that sort.

I've now made a test version of this applet so I can fiddle more than I 
could with the version that in use by our software.  One of the things I can 
now test is whether the problem is reading the file or sending out the 
response string. 






==========================================================================
TOPIC: runtime.getRuntim().exec(somecmd) problem with linux
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a3f83ceedc3184b0
==========================================================================

== 1 of 3 ==
Date:   Fri,   Nov 5 2004 9:07 am
From: [EMAIL PROTECTED] (wex) 

Gordon Beaton <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 4 Nov 2004 21:07:29 -0800, wex wrote:
> > I have used this kind of functionality many times:
> > Runtime rt = Runtime.getRuntime();
> > Process process = rt.exec(somecmd);
> > 
> > However I have run into a problem where it will not work when the
> > command contains a path with spaces in it on a linux platform. For
> > instance a string that executes any random exec.
> > Runtime rt = Runtime.getRuntime();
> > Process process = rt.exec("/path with space/somecmd.bat");
> 
> When you use Runtime.exec(String), the string is passed to a
> StringTokenizer that breaks the string at whitespace only (i.e.
> without regard to any extra quotes) and puts the resulting tokens into
> an array. It then calls Runtime.exec(String[]) with the command array.
> 
> Obviously this will not work when you have whitespace in the command
> or any of the arguments.
> 
> > I have also tried putting the command in a string array like so:
> > String[] cmds ={"\"/path with space/somecmd.bat\""};
> > Runtime rt = Runtime.getRuntime();
> > Process process = rt.exec(cmds);
> > This results in the same error with or without the quotes.
> 
> In my experience, this works as expected if you lose the extra quotes.
> Just make sure you put the command name and the arguments into a
> single element of the array *each*. Exactly what error do you get?
> 
> /gordon

Thanks, but that doesn't seem to work, I get a java.io.Exception in
the case where it is a single element just a path and command and if
the command is not in a spaced path but one of the arguments has one
it just doesn't work.

I am aware of the string tokenizer effect and thought the solution
would be to pass the whole command string as one element in a String
array because then it would not be manipulated further but that
doesn't seem to work.   One of the obstacles I am facing is this path
is dependant on the install location of the app, which is up to the
user installing it.  Additionally, the app is suppose to work
seamlessly on windows, linux and mac so even though there may be some
platform specific solutions I am trying to avoid them.

I guess the big question is what happens to the command string after
the string tokenizer parses it?  Because just running the simple
command:
String[] cmd = {"/path with space/somecommand"};
runtime.getRuntim().exec(cmd); 
Gives me the io exception, it is as if the command is tokenized again
somewhere in the native code.
Help???



== 2 of 3 ==
Date:   Fri,   Nov 5 2004 9:17 am
From: Gordon Beaton <[EMAIL PROTECTED]> 

On 5 Nov 2004 09:07:45 -0800, wex wrote:
> Thanks, but that doesn't seem to work, I get a java.io.Exception

What is the full text of the exception message?

> I guess the big question is what happens to the command string after
> the string tokenizer parses it?

AFAIK, nothing.

> Because just running the simple
> command:
> String[] cmd = {"/path with space/somecommand"};
> runtime.getRuntim().exec(cmd); 
> Gives me the io exception, it is as if the command is tokenized again
> somewhere in the native code.

Try running a short program that does (just) the above, using strace:

 strace -f -o strace.log java Testprog

Then look for the command string in the logfile.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




== 3 of 3 ==
Date:   Fri,   Nov 5 2004 12:02 pm
From: Steve Horsley <[EMAIL PROTECTED]> 

wex wrote:
> I have used this kind of functionality many times:
> Runtime rt = Runtime.getRuntime();
> Process process = rt.exec(somecmd);
> 
> However I have run into a problem where it will not work when the
> command contains a path with spaces in it on a linux platform. For
> instance a string that executes any random exec.
> Runtime rt = Runtime.getRuntime();
> Process process = rt.exec("/path with space/somecmd.bat");


A wild guess that I haven't actually tried - try:
    Process process = rt.exec("/path\\ with\\ space/somecmd.bat");

Steve




==========================================================================
TOPIC: Performance of null tests?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e1febd5672a2f269
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 9:14 am
From: [EMAIL PROTECTED] (Adam) 

Wow - that's a lot of responses, cheers everyone!

That is what I suspected and our next step will be to evaluate a load
of different points in the code with this in mind.  Based on the
likelihood of a null scenario!

Just to give a bit of context, this is part of a server side method
called heavily by a multitude of clients - ergo performance is
paramount, easily readable code can be sacrificied (but mitigated with
verbose comments, one hopes).

And no, I'm not a student ;)




==========================================================================
TOPIC: Apache Axis and JDK1.5
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/274cfa6bf37ead9b
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 9:18 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"Jacob" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Mike Schilling wrote:
>
>> Try what I suggested last time you brought this up: use the "-source 1.4" 
>> flag on javac.
>
> Excuse me for repeating myself.
>
> What I actually did this time was to use Apache Axis 1.2rc
> (my previous request was regarding Apache Axis 1.1).
>
> I know I can get this running using 1.4 option, but then
> again there would be no use of JDK1.5, would there?

Except in the files that need to reference the "enum" packages directly, you 
could use all the 1.5 features you like.  Of course, when it comes time to 
deploy your web services, you'd need to put them in a container that 
supports 1.5.  AFAIK, that wouldn't be any of the large commercial ones 
(WebLogic, WebSphere, etc.) yet.  Not sure about Tomcat, JBoss, etc. 






==========================================================================
TOPIC: Building an Exception Layer
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a8359d1a0e5422fb
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 5 2004 9:04 am
From: "Rizwan" <[EMAIL PROTECTED]> 

the reason of using base is because I was thinking to define it as an
abstract class.

"Chris Smith" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Rizwan wrote:
> > then it would be MITBaseException (MIT being the software product name
which
> > we are creating). But then I have to include MIT with other exception
name
> > as well for example MITPermissionException, etc.
>
> That's the basic idea.  I'd suggest MITException as opposed to
> MITBaseException.  The "base" is still an implementation word, and just
> grates a bit when used from a client.  The client shouldn't care if it's
> a "base" for some other exception; only if it's the exception the client
> is interested in.  As for "MITPermissionException", that's probably a
> good idea just because "permission" is so vague.  For a less vague word,
> it might not be necessary; for example, FileNotFoundException is not
> called IOFileNotFoundException, because the name is descriptive enough.
>
> -- 
> www.designacourse.com
> The Easiest Way To Train Anyone... Anywhere.
>
> Chris Smith - Lead Software Developer/Technical Trainer
> MindIQ Corporation





== 2 of 2 ==
Date:   Fri,   Nov 5 2004 1:03 pm
From: Chris Smith <[EMAIL PROTECTED]> 

Rizwan wrote:
> the reason of using base is because I was thinking to define it as an
> abstract class.

I don't see why it would matter to me, if I'm writing code to use your 
library, whether the exception class is abstract or not, just as it 
doesn't matter whether it's a base class or not.  In either case, when I 
want to catch all exceptions thrown by your framework, the code and 
purpose is the same and it makes more sense to catch MITException, not 
MITBaseException.

Remember what inheritance is: it expresses an "is a" relationship; basic 
first-level programming course stuff.  When you insist on putting base 
in the name, you're causing discongruency for someone who writes:

    ...
    catch (MITBaseException e)
    {
        ...
    }

The exception being caught isn't a "base" exception.  It's a quite 
specific exception, perhaps relating to permissions or structure.  Your 
code reads wrong.

-- 
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==========================================================================
TOPIC: How can I change the location of the Web Start cache?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4aabb51e96392879
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 10:00 am
From: Tarlika Elisabeth Schmitz <[EMAIL PROTECTED]> 

Hello Andrew,
After a little further investigation, here are my conclusions:

Andrew Thompson wrote:
> On Thu, 04 Nov 2004 14:56:08 +0000, Tarlika Elisabeth Schmitz wrote:
> 
>>In case you're reading this, Andrew, I've got a new challenge for you: 
>>(I heard on the grape-vine ...
> 
> Whoever said that?  
> 
>>..that you're a bit of a WebStart specialist ;-) )

Got my sources ... 8-)

>>1) I want to pre-install the cache and provide an icon to the 
>>application (desktop integration).
> 
> 
> I do not quite follow.  Do you mean as distinct to the shortcuts 
> that JWS creates for the application itself?

I see the following, albeit minor, problems with the JWS solution. As I 
mentioned earlier, for this particular app, JWS is a convenience 
solution. I want our customer to automagically pick up the latest 
version from their local server, to which we have remote access.

The user shouldn't have to know anything about webstart. I just want 
them to click their application icon, which fires up the application and 
if need be downloads the latest jars. I don't want them to get prompted 
about desktop integration and certificates.

Only when you run JWS for the first time (javaws XXX.jnlp) will the user 
be confronted with those prompts. Second time round, even without 
desktop integration*, the application will just fire up. Great. So, all 
that is needed, first execution by hand before the user gets to click 
around.

*I'm not quite sure now, what's the point of the desktop integration? I 
can simply create a shortcut which executes "javaws XXX.jnlp". Or am I 
missing something?

But: the location of the cache is in the home directory and the user 
could - theoretically - delete the cache, in which case he would get 
above prompts. The cache can be directed elsewhere via the JWS console 
(just call javaws without args). But then all Webstart apps including 
those the user might find on the internet would go in that location.

In any case the cache directory needs the user's write permissions 
because javaws is executed under the user's id, not with an s-bit on 
Unix. So, there is no way you could prevent him from deleting the cache 
by mistake or otherwise. No point in re-locating the cache then anyway.

> Based on the 'JWSCache' string, on which the only reference
> was the Sun forums, I found my way to this..
> <http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/properties.html>

1.5 - I leave this to those who want to be Sun's testers. I'll look at 
it when it's mature.

>>I think there used to be a javaws.cfg file but there isn't any longer. 
>>Where are all these settings stored now?

OK, I think I now know what happened. This week, when I started looking 
at JWS, I realized that I had two versions of it on my Win2K machine: 
one is part of the JRE 1.4.2, the other one was a standalone 
installation. Judging by the file dates, I must've installed the latter 
prior to 1.4. Presumably, before 1.4 JWS was not part of the JRE. This 
version had a javaws.cfg file, which so many people mentioned on the 
net. A lot of the articles are found were dated 2002.


> [ This is of interest to me since I want to deploy Saverbeans
> ScreenSavers to Win/*nix boxes using JWS, but they need to be 
> installed in specific directories.  * But, to be honest, your 
> post has got me closer to that goal than all my earlier 
> investigations!  ;-)  ]

I think this can only be achieved if you write your own javaws 
equivalent. Maybe I'm wrong. At least under 1.4.2 I can't see a solution.

-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz




==========================================================================
TOPIC: Implementing Legacy Byte Packed Message Interfaces
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a17f0bc392a7f7
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 10:04 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Chris wrote:

> [...] legacy systems that implement
> messages as C Structs many of which use C bit notation ( message
> fields may represent bit masks that are not on byte boundaries).

The C bit notation should never be, and should never /have/ been, used to
specify in-memory layout.

The layout of bitfields is almost totally non-portable.  IIRC, the only defined
requirement is that they appear in memory in the same order as they do in the
source, how much padding -- if any -- is between them is totally implementation
specific.  There might be problems with signedness too, but my memory of that
aspect of the standard has faded completely :-(

(All the above, of course, is true for C structs in general, but bitfields are
even worse than usual because there seems to be a nearly irresistible
temptation for C programmers to abuse them.)

In essence you will have to do exactly what you would do if you were
interfacing with those legacy systems using C.  Find out how the compiler for
the legacy code lays out the data in memory, read the data in as some primitive
type (byte or int seems natural), and define appropriate bitmasks that overlay
the layout to extract the data you want.

I would avoid JNI for this sort of thing, if I were you -- all you are doing is
putting off the problem (which is really caused by whoever it was who thought
you could use C structs and bitfields to define memory layout portably), and
the cost of crossing the JNI boundary is quite high (I put it at in the order
of magnitude of 1 usec on the machines I use).

    -- chris








==========================================================================
TOPIC: Looking for a jar manager in java.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/21cca5a7232d050f
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 9:40 am
From: <@> 

I'm looking for a jar manager o.s.-free in java. I need to read and
manipulate jar contents even changing (adding, renaming and deleting) files
inside (resources and ".class" file) e.g. exporting a "class" object inside
it.

Thank you.




----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---




==========================================================================
TOPIC: Tomcat responce time 10-200 seconds once in a while
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eff0206fed26be06
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 10:16 am
From: Roman Zhovtulya <[EMAIL PROTECTED]> 

Dear all,
I wonder if anyone had anything similar before.
I'm running some JSP/Java Bean websites under Tomcat (on one PC as a 
stand-alone server, on another in connection with Apache).

The website is a dynamic (3-tier architechture) connects to MySQL 
database to get the content to display any page (around 3-4 connections 
per page).

Normally the performance is really good, but about once a day it gets 
really slow (around 1-5 minutes to display the page). It also recovers 
autocatically to normal response time when you simply wait 5-10 minutes.

Any ideas?

I'm running Tomcat 4.05 with Apache on RedHat 8.0 (one PC) as well as 
Tomcat 4.127 on SuSE 9.0 with MySQL 4.015.

I'm closing all db-connections in JSP/JavaBeans, so I don't think it's a 
db-issue.

I'd highly appreciate any help on the topic.

Thank you very much,
Roman Zhovtulya




==========================================================================
TOPIC: Good Annotation Intro
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6586a2e918c9a5b8
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 10:21 am
From: "Stefan Schulz" <[EMAIL PROTECTED]> 

I've been playing around with the new features in 1.5 for a
while now, save one: Annotations. The information i have found
so far has been far less then satisfactoy. Is there any in-dept
introduction / tutorial?


See you
Stefan

-- 

Whom the gods wish to destroy they first call promising.




==========================================================================
TOPIC: .getRuntime().exec() - with long command
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/642cef59562edc6e
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 5 2004 10:21 am
From: petr cezar <[EMAIL PROTECTED]> 

hello,

i'm trying to run 'keytool' program from within my application by this way:

   String cmdline = "keytool -genkey" +
     " -dname \"cn=" + "MyName" + ", ou=" + "Development" + ", o=" + "IBM" + ", c="+ 
"CZ" + "\"" +
     " -keyalg " + "DSA" +
     " -keysize " + 1024 +
     " -alias " + "MujFirstKey" +
     " -keypass " + "somepasswd" +
     " -keystore " + "/home/petr/MyKeystore" +
     " -storepass " + "somepasswd" +
     " -validity " + 180;

   try {
    Process p = Runtime.getRuntime().exec(cmdline);
   .......

but 'keytool' always prints out only some help messages and that's all.
it seems like some of the command parameters are not in correct form, mabye
spaces or those in quotes, but i don't know...

does anybody know what's wrong with that code?

thank you very much,
and, please, excuse my pure english
-petr




== 2 of 2 ==
Date:   Fri,   Nov 5 2004 10:27 am
From: Gordon Beaton <[EMAIL PROTECTED]> 

On Fri, 05 Nov 2004 19:21:24 +0100, petr cezar wrote:
> i'm trying to run 'keytool' program from within my application by this way:
> 
>    String cmdline = "keytool -genkey" +
>      " -dname \"cn=" + "MyName" + ", ou=" + "Development" + ", o=" + "IBM" + ", c="+ 
> "CZ" + "\"" +
>      " -keyalg " + "DSA" +
>      " -keysize " + 1024 +
>      " -alias " + "MujFirstKey" +
>      " -keypass " + "somepasswd" +
>      " -keystore " + "/home/petr/MyKeystore" +
>      " -storepass " + "somepasswd" +
>      " -validity " + 180;
> 
>    try {
>     Process p = Runtime.getRuntime().exec(cmdline);
>    .......
> 
> but 'keytool' always prints out only some help messages and that's
> all. it seems like some of the command parameters are not in correct
> form, mabye spaces or those in quotes, but i don't know...
> 
> does anybody know what's wrong with that code?

Try it like this instead:

  String[] cmdline = {
    "keytool",
    "-genkey",
    "-dname",
    (etc...)
  }

i.e. exactly one argument per array element, without any extra quotes
(spaces shouldn't matter).

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==========================================================================
TOPIC: slow network image transfers
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fa5c2246b272494
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 11:09 am
From: [EMAIL PROTECTED] (Morris) 

"Andrei Kouznetsov" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> yes, you should send pixel array (int[] or byte[]).
> Good idea is to use ZipOutputStream and ZipInputStream.

Hi,

Thanks, I've changed to using the int[] method.  I've enclosed bits of
relavent code below for anyone interested.

I wonder if the time required to create a ZIP stream is longer than
the time to just send the data directly though.  This would probably
be an interesting test for another time.

FYI, my transfer time is about 150-200 ms for a 1024x768 image.  This
is with an AMD64 3200 processor, 1GB of memory and gigabit network.

thanks,

morris



BufferedImage bi = new BufferedImage(1024, 768,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bi.createGraphics( );

public boolean connect() {
        try {
                socket = new Socket(ServerAddress, 1999);
                dos = new DataOutputStream(new
BufferedOutputStream(socket.getOutputStream(), 1024));
                return true;
        }
        catch(Exception e) {
                System.out.println(e.getMessage());
                return false;
        }
}

public void sendImage(Image img) {
        g2d.drawImage(img, null, null);
        pixels = getPixels(bi);
        try {
                int[] pixInt = (int[])pixels;
                for (int i = 0; i < pixInt.length; i++) {
                        dos.writeInt(pixInt[i]);
                }
                dos.flush();
        }
        catch(Exception e) {System.out.println(e.getMessage());}        
}

public Object getPixels(BufferedImage bimg) {
        PixelGrabber grabber = new PixelGrabber(bimg, 0, 0, -1, -1, true);
        try {
                grabber.grabPixels();
        }
        catch (InterruptedException e) { }
        Object pix = grabber.getPixels();
        return pix;
}




==========================================================================
TOPIC: Is it possible to set a block of code as non-JIT area?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/efa6df384a75654c
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 5 2004 11:44 am
From: [EMAIL PROTECTED] (jacksu) 

For the rest of the code, I would like the JIT to do the magic, but
for certain portion of the java code, I would make it untouched by the
JIT.

I am using IBM websphere 5.0.2, with JDK1.3.1_08

Thanks



== 2 of 2 ==
Date:   Fri,   Nov 5 2004 1:01 pm
From: "John C. Bollinger" <[EMAIL PROTECTED]> 

jacksu wrote:

> For the rest of the code, I would like the JIT to do the magic, but
> for certain portion of the java code, I would make it untouched by the
> JIT.

Why?

The answer is academic, I think, because although there might be a way 
to disable JIT globally, there is no way to disable it only for specific 
sections of code.  JIT is outside the scope of the Java and bytecode 
languages -- they have no way to express instructions about it.  So what 
is the goal underlying your inquiry?


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: Parsing a string into a proper Java Date
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8fa1b8c1f74c2e37
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 11:49 am
From: "Jbjones" <[EMAIL PROTECTED]> 

I am not sure what the best way to parse a Z formatted time (GMT) into
my format.  Here is an example date string and the parse string I would
like to smehow use:

String to parse:              2004-10-21T20:00:00-04:00
Format string to use:
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

I am not sure if i need to change my time zone from Eastern to GMT to
process then change it back, or what to do.  That offset number is the
proper amount to go from GMT(Z) to EDT.  Thanks for the help.





==========================================================================
TOPIC: Thread-question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 11:55 am
From: "xarax" <[EMAIL PROTECTED]> 

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> FWIW, and depending on the what you are trying to accomplish, you may
> not have to explicitly wait for the worker thread to finish. In the
> absence of an explicit  call to  System.exit(), your application won't
> exit until all (non-daemon) threads have exited.

The AWT EDT is non-daemon, thus the call to System.exit()
is required to shutdown the JVM.

Just put the System.exit(0) call in the other
thread that performs the clean-up. Don't bother
with Thread.join() in the EDT; it will just hang
the GUI.






==========================================================================
TOPIC: What is the best way to restart a thread?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a59e302ccfd155f9
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 12:13 pm
From: Steve Horsley <[EMAIL PROTECTED]> 

Ken Adams wrote:
> How does a guy go about restarting a finished thread? I have a class that 
> extends thread and I want to be able to restart it once it has finished his 
> task. Is there anyway I can get the thread to restart itself by say having a 
> method which I can call. Thanks

As Gordon says, you cannot restart a dead Thread.

I always advise that you use Runnables instead of extending Thread, to reduce
the confusion that arises when one Thread's thread calls another Thread's 
methods. Another benefit in this case is that you can always start another 
Thread on an existing Runnable, which probably achieves the restart that you 
are looking for.

Of course, you can always start a new Thread on an existing Thread, because 
a Thread is Runnable. But perverts like that don't get let out very often,
fortunately.

Steve




==========================================================================
TOPIC: Rational Rose - reverse engineering - no attributes
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/609ab2a87ee5f47b
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 12:19 pm
From: "VisionSet" <[EMAIL PROTECTED]> 

Managed to reverse engineer java source,
but all the attributes are missing.
Anyone done this?

v 2001.03

-- 
Mike W






==========================================================================
TOPIC: File transfer to FTP site
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9647b579b1a148
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 1:00 pm
From: [EMAIL PROTECTED] (raj) 

Hi
I want transfer some files to an ftp site, (actually a specified
folder in the ftp site).
What is the easiest way to do this ?? 
I have downloaded various bits of code and they all seem to require
the host name as string ie "ftp.yahoo.com" 
ie Socket s = new Socket("ftp.yahoo.com", defaultport)
I want to be able to specify an ftp url, ie
"ftp:\\194.128.10.195\myName"
and transfer files to this.

I usually programme in Smalltalk, and my knowledge of Java is limited.

Thanks for your Help
Raj



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to