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

Today's topics:

* Manifest file and Classpath issue - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/46fa54f4641507da
* How do you cast to array? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47
* ot: DDR memory stick - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56a53ac61d0c8e1d
* A function in JavaBean need help - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16b06f93864cc54f
* How do you report a JIT crash bug? - 4 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e12e8e3c39c7cc4
* multi-inheritance between EntityBeans - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c56b1038efd7ffbb
* rmi and object references - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9499209acc98049d
* optimizeit: how to workaround/minimize wrong cput time in Object.wait() - 1 
messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28
* JavaMail Error - AuthenticationFailedException - 4 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c949afd643ddaab
* Implementing Legacy Byte Packed Message Interfaces - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c7a17f0bc392a7f7
* java.net.SocketException: Insufficient buffer space - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c9c56b240ed60b1
* Classes SSH-SCP for Java - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b78404f5308632ce
* Thread-question - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
* Redirect stdin using "<" in process started w/ Runtime.exec()? - 2 messages, 2 
authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/774e28df351c13
  
==========================================================================
TOPIC: Manifest file and Classpath issue
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/46fa54f4641507da
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 2:47 am
From: Frank Buss <[EMAIL PROTECTED]> 

skydvr <[EMAIL PROTECTED]> wrote:

> jarfile, the "dataFile" in question would be under a "data" dir - not at 
> the top level.  It doesn't seem to work to give the "jar" cmd two 
> separate "-C" parameters, and having the data file under a "data" dir is 
> probably preferable.

I don't know, if you can use two "-C" parameters, but you can rename the 
jar-file to a zip file (because it is the same format) and unzip it to take 
a look what was generated.

And try to use getResourceAsStream("/datadir/datafile") (or "/datafile", if 
you have packed it in root in the jar).

-- 
Frank Buß, [EMAIL PROTECTED]
http://www.frank-buss.de, http://www.it4-systems.de




==========================================================================
TOPIC: How do you cast to array?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/884dee2def4bbb47
==========================================================================

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

NOBODY wrote:

> (I cannot believe the % of coders forgetting that 'new' is expensive...)

The question is: /how/ expensive ?

Go on, take a guess.  How many milliseconds ? Or is it measured in
microseconds ?  Or even nanoseconds ?  Take a guess, before you read on...

Here's some test code:

====================
public class Main
implements Runnable
{
 private final int m_steps;

 public static void
 main(String[] args)
 {
  new Thread(new Main(100)).run();
 }

 Main(int steps)
 {
  m_steps = steps;
 }

 public void
 run()
 {
  for (;;)
  {
   tick();
   tock();
  }
 }

 void
 tick()
 {
  int steps = m_steps * 1000000;
  int[] array = new int[0];
  int totalSize = 0;

  long start = System.currentTimeMillis();
  for (int i = 0; i < steps; i++)
  {
   totalSize += array.length;
   array = new int[0];
  }
  long end = System.currentTimeMillis();
  double secs = (end - start) / 1000.0;

  System.out.print(m_steps + "M arrays allocated in " + secs + " seconds");
  System.out.println(", total size: " + totalSize);
 }

 void
 tock()
 {
  int steps = m_steps * 1000000;
  int[] array = new int[0];
  int totalSize = 0;

  long start = System.currentTimeMillis();
  for (int i = 0; i < steps; i++)
   totalSize += array.length;
  long end = System.currentTimeMillis();
  double secs = (end - start) / 1000.0;

  System.out.print("zero arrays allocated in " + secs + " seconds");
  System.out.println(", total size: " + totalSize);
 }
}
====================

On my machine, a 1.5Gz laptop, it sits in a steady loop allocating 0-length
arrays at a rate of around 40M per second (about 25 nanoseconds a go).  The
reported times scale with both 'm_steps' and the size of the allocated arrays
so I don't think the allocations are being optimised away.  (I did try
with -server too, and that's marginally quicker as you'd expect, and that
/does/ optimise the empty comparison loop (tock()) out completely, but not the
allocations afaict.)

There are contexts where allocation is slower than that -- not everyone is
running code on desktop class or more machines.  Also there are contexts where
25 nanosecs is a long time -- though I doubt if many people reading this are
working in such a context.  So, while I don't entirely disagree with you that
"'new' is expensive", I think that a better way to express it (for general
purposes) is that 'new' is /cheap/.

    -- chris







==========================================================================
TOPIC: ot: DDR memory stick
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/56a53ac61d0c8e1d
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 2:53 am
From: "Bruce Lee" <[EMAIL PROTECTED]> 

I would like to add a 512 DDR memory stick to my PC, but I am insure which
type to buy. The memory currently installed in my system has 1 cut-out on
the gold side (slightly off center) but all the memory I have seen has 2
cut-outs. Would it matter if I bought the stick with 2 cut-outs?

cheers ears






==========================================================================
TOPIC: A function in JavaBean need help
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16b06f93864cc54f
==========================================================================

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

Hello

I am new with JavaBean. When I read this function in a Java project to add
Name:


public void addName(NameDTO name) {
try {

ActionPlanGatewayUtil.getHome().create().addName(userInform.setSessionID(),
name);
     }
.....

To understand this code, I tried to see the code for this
ActionPlanGatewayUtil class but did not see any detail of this class
(functions, attribute) or how it was created. I think that this class is a
EJB object but I do not have any clue. If you have any idea about this class
(general idea), please help...

Thank you
S.H1






==========================================================================
TOPIC: How do you report a JIT crash bug?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e12e8e3c39c7cc4
==========================================================================

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

Thomas Weidenfeller wrote:

> Pay them. No joke. Sun offers professional services, where experts even
> come down to your site and look at the stuff.
>
> I never did this for Java, but I went through this a few times, e.g.
> when hunting nasty bugs in their C/C++ compiler.

/You/ pay /them/ to look for bugs in /their/ software ?  Wow !

Now that's the business to be in...

    -- chris





== 2 of 4 ==
Date:   Fri,   Nov 5 2004 2:59 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Chris Uppal wrote:
>>Pay them. No joke. Sun offers professional services, where experts even
>>come down to your site and look at the stuff.
>>
>>I never did this for Java, but I went through this a few times, e.g.
>>when hunting nasty bugs in their C/C++ compiler.
> 
> 
> /You/ pay /them/ to look for bugs in /their/ software ?  Wow !
> 
> Now that's the business to be in...

That's how most software development works. Note that the emphasis is
more like: /You/ pay them to look for bugs in their software that
/you/ need fixed.



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

"Chris Uppal" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> /You/ pay /them/ to look for bugs in /their/ software ?  Wow !
>
> Now that's the business to be in...

The part of our software with the JIT crashes is only needed by 5% of our 
users, those who contribute information to our database, so we can get them 
to use the Microsoft JVM or use a Macintosh.  Hopefully someone else will 
notice the problem in a simpler context and report it, or be so dependent on 
Sun than they are willing to pay to fix Sun bugs. 





== 4 of 4 ==
Date:   Fri,   Nov 5 2004 6:57 am
From: "Mickey Segal" <[EMAIL PROTECTED]> 

I looked through the crash logs and they don't seem to reveal anything that 
can't be released so I posted two at www.segal.org/java/sun_jit/.  If anyone 
has any clues about how to read such tea leaves in a way that would help Sun 
fix the bug or help me work around it I'd be interested.  A lot of Java 
methods are mentioned but it doesn't seem as easy to interpret as a typical 
Exception trace in a Java Console. 






==========================================================================
TOPIC: multi-inheritance between EntityBeans
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c56b1038efd7ffbb
==========================================================================

== 1 of 2 ==
Date:   Fri,   Nov 5 2004 3:00 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

Grzegorz Trafny wrote:
> Excuse me, I can't believe, nobody knows what to do?

Because there isn't much to do. You don't have multiple inheritance in 
Java. Period. If you base your design on multiple inheritance you are 
shooting yourself in the foot. Don't shoot yourself in the foot is the 
best advice, change your design.

If you want to hack around it, use interfaces and a lot of bridging 
code, use a code generator, or use another language.

/Thomas




== 2 of 2 ==
Date:   Fri,   Nov 5 2004 3:41 am
From: [EMAIL PROTECTED] (Andrei) 

"Grzegorz Trafny" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> "Hal Rosser" wrote:
> 
> > > Question is lightly theoretical but how to implement project
> > > (for example: data model ) in which was used multi-inheritance?
> > > Especially, how to model multi-inheritance in apps which data
> > > is based on EntityBeans?
> 
> [cut]
> 
> > you can try (drum roll)
> > implementing multiple interfaces
> 
> Not exactly, I meant situation where project directly show that
> (for example) 3 entities are dependent like these:
>     "ClassC extends ClassA, ClassB"
> and everyone class must has instance variables.
> 
> What Java programmer should do in that situation?
> Is the only way out from this situation is change of
> project, how better to do this?
> 
> Greetings
> GT


you could use delegates, for what is possible




==========================================================================
TOPIC: rmi and object references
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9499209acc98049d
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 5:05 am
From: [EMAIL PROTECTED] (kevin) 

hi,

I've got a problem trying to reference a remote object via a
reference.

I have a series of database classes subclassed from dbAccess, and a
remote method Map getTables() that returns a map (String tablename,
dbAccess table)

I can run this method, and locally cast out subclasses then user their
methods.
When I try to use this class reference in a method call, it seems to
use the class i changed locally, but not return it...

Anyone got an idea why it won't work an how to go about fixing /
avoiding it?

local code

rs.authorise("test", "user", "password");  // rmi authority check
            
tables = rs.getTables();    // read map of dbAccess classes
            
cust = (Customer) tables.get(cust.tableName); // get instance
            
cust.setId("   101");      // use instance function to set key fld
blnOK = rs.readRow(cust);  // call remote method using class ref.
            
if (blnOK) {               // this returns true as it found key
                           // but the name is blank.
      System.out.println("customer 101 is " +  cust.getName());
}             


server code
    public boolean readRow( dbAccess table) throws RemoteException,
RemoteSQLException {
        boolean blnFound = false;
        
        if (livedb == null) {
            throw new RemoteSQLException("No Connection");
        }
            
        try {
            blnFound = table.readRow(livedb);
        } catch (SQLException sqle) {
            blnSQLError = true;
            throw new RemoteSQLException(sqle.getMessage());
        } finally {
            // only kill connections if sql error happened
                
            if (blnSQLError) {
                dropConnections();
            }
        }
        Customer cust = (Customer) table;
        System.out.println("found row " + cust.getName());
        tableclasses.put(table.tableName, table);
        return blnFound;
    }

this code correctly prints out the customer name to the console, yet
the class
reference is not updated locally, because that prints null.




==========================================================================
TOPIC: optimizeit: how to workaround/minimize wrong cput time in Object.wait()
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28
==========================================================================

== 1 of 1 ==
Date:   Fri,   Nov 5 2004 5:07 am
From: "Robert Klemme" <[EMAIL PROTECTED]> 


"NOBODY" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Hi,
>
> Optimizeit reports imprecise cpu time in Object.wait()

Times for Object.wait() are quite uninteresting IMHO because you can't
change them anyway.  Also, Object.wait() does not much - most of the time
spent in this methods a thread is stopped because it waits for
Object.notify() (or notifyAll()).  The overhead of recording this thread's
status etc. is neglectible IMHO.

>  even though you use
> record only cpu usage. (also stream read,
>  Thread.sleep, etc...)
>
> (partially explained in
>
http://groups.google.com/groups?q=optimizeit+Thread.sleep+Object.wait&hl=en&lr=&safe=off&selm=41008621%241%40newsgroups.borland.com&rnum=1
> )
>
>
>  ????? Is there anyways to work it around or minimize that effect?
>
>
> Whether I use sampling or instrumentation mode, it is
>  very off by large fraction of thread time share%.

How did you determine that it's that far off?

> Changing sampling interval didn't help either.
>
> I'm stuck! Feel like this 800$ piece of software is useless!
> (optimizeit profile 4.2 enterprise edition, build 020502,
> in case you know anything about that version)

I find OptimizeIt very useful.  Maybe you just use it the wrong way.  What
exactly is it that you want to determine?

Kind regards

    robert





==========================================================================
TOPIC: JavaMail Error - AuthenticationFailedException
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1c949afd643ddaab
==========================================================================

== 1 of 4 ==
Date:   Fri,   Nov 5 2004 5:35 am
From: "TC" <[EMAIL PROTECTED]> 

Java 1.4.2
JavaMail API 1.3.2
NetBeans 4.1


I have done quite a bit of research on this issue and cannot find the
problem.  I've even checked with one of our local programmers.

I created one program that connects to our smtp server and sends an
email.  This works fine.  Now, I'm trying to create a program that
connects to the smtp server and reads/gets the email message subjects.
This is failing.  I have tried changing the getStore("pop3") to
getStore("smtp") but this gives the error "Invalid provider".  If I use
caps (SMTP), I get "No provider for SMTP".

The host I'm using is the same as what I use to send mail.  I have
mail.jar and authentication.jar in my Project Compiling Sources dir.
I'm guessing it means it's in my CLASSSPATH.

The META-INF file found in the JavaMail\lib\ dir contains .jar files
for pop3 and smtp.  Do I need to add my host to the smtp.jar file?


  Here's my code:

*
* ReadMail.java
*
* Created on November 4, 2004, 10:20 AM
*/
/**
*
* @author jmartin
*/
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class ReadMail {
public static void main (String agrs[])
throws Exception {
try {
String host = "server.mydomain.com";
String userName = "";  // Has a valid username
String password = "";  // Has a valid passwd
// Create empty properties
Properties props = new Properties();
// Get session
Session session = Session.getDefaultInstance(props, null);
// Get the store
Store store = session.getStore("pop3");
store.connect(host, userName, password);
// Get folder
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
// Get directory
Message message[] = folder.getMessages();
for (int i=0, n=message.length; i<n; i++){
System.out.println(i + ": " + message[i].getFrom()[0]
+ "\t" + message[i].getSubject());
}
// Close connection
folder.close(false);
store.close();
} // try
catch (Exception e){
System.out.println("There was an error.");
e.printStackTrace();
}
} // main
}



== 2 of 4 ==
Date:   Fri,   Nov 5 2004 6:38 am
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 

You can set Javamail to run in debug mode via Session.setDebug(true) or
setting the "mail.debug" property (props.put("mail.debug", "true")):
http://java.sun.com/products/javamail/FAQ.html#debug

Beyond that, and at the risk of asking the obvious, are you sure you're
specifying a valid server, e-mail account, and password when trying to
connect? Is your POP server different than your SMTP server? Can you
use telnet to connect via POP using the same information you're using
with the Java code?




== 3 of 4 ==
Date:   Fri,   Nov 5 2004 7:16 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

TC wrote:
> I created one program that connects to our smtp server and sends an
> email.  This works fine.  Now, I'm trying to create a program that
> connects to the smtp server and reads/gets the email message subjects.
> This is failing.  I have tried changing the getStore("pop3") to
> getStore("smtp") but this gives the error "Invalid provider".  If I use
> caps (SMTP), I get "No provider for SMTP".

In a typical "home user" setup you use SMTP and POP3 (or IMAP) for 
different things. Simplified:

SMTP: To send mail from your desktop computer.
POP3: To read mail from the mailbox which your ISP provides.

So, don't be surprised that getStore("smtp") fails, this is not the 
protocol for reading data from a mailbox at your ISP, and there is no 
point in trying - it can't work in this scenario (that's why a separate 
protocol like POP3 was invented).

Often, the SMTP server and the POP3 server of an ISP are not the same, 
so this might be a source of your problems. So you better check twice if 
you really provide the correct data.

> // Get folder
> Folder folder = store.getFolder("INBOX");
> folder.open(Folder.READ_ONLY);

I remember that get-folder part slightly different, but I can't check at 
the moment. I think one was first supposed to get the default folder.


> // Close connection
> folder.close(false);
> store.close();
> } // try

You should move the close() to a finally block to ensure they are always 
called (plus appropriate checks that you don't invoke the close() 
methods on null references).

/Thomas



== 4 of 4 ==
Date:   Fri,   Nov 5 2004 7:57 am
From: "TC" <[EMAIL PROTECTED]> 

Thomas Weidenfeller wrote:

> TC wrote:
> > I created one program that connects to our smtp server and sends an
> > email.  This works fine.  Now, I'm trying to create a program that
> > connects to the smtp server and reads/gets the email message
> > subjects.  This is failing.  I have tried changing the
> > getStore("pop3") to getStore("smtp") but this gives the error
> > "Invalid provider".  If I use caps (SMTP), I get "No provider for
> > SMTP".
> 
> In a typical "home user" setup you use SMTP and POP3 (or IMAP) for
> different things. Simplified:
> 
> SMTP: To send mail from your desktop computer.
> POP3: To read mail from the mailbox which your ISP provides.
> 
> So, don't be surprised that getStore("smtp") fails, this is not the
> protocol for reading data from a mailbox at your ISP, and there is no
> point in trying - it can't work in this scenario (that's why a
> separate protocol like POP3 was invented).
> 
> Often, the SMTP server and the POP3 server of an ISP are not the
> same, so this might be a source of your problems. So you better check
> twice if you really provide the correct data.

In the process now.

> 
> > // Get folder
> > Folder folder = store.getFolder("INBOX");
> > folder.open(Folder.READ_ONLY);
> 
> I remember that get-folder part slightly different, but I can't check
> at the moment. I think one was first supposed to get the default
> folder.

I can use getDefaultFolder but debug gives "The requested mailbox is
not available on this server".

> 
> 
> > // Close connection
> > folder.close(false);
> > store.close();
> > } // try
> 
> You should move the close() to a finally block to ensure they are
> always called (plus appropriate checks that you don't invoke the
> close() methods on null references).

Will do.




==========================================================================
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 5:38 am
From: [EMAIL PROTECTED] (Chris) 

We are currently working on a project where new Java based sub-systems
are being created to replace legacy ADA implementation. The Java
inter-component communication is being realized by Java JMS. The
architecture provides for "boundary" components that will be
responsible for communicating with 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). We
have been looking at using Java JNI to perform the packing/unpacking 
to/from Java Objects and C Structs. What other alternatives exist?  It
was suggested that we create Java implementation to do all of the
pack/unpack.  This would work for primitive types but would break down
when dealing with legacy fields that  are bit masks. I have briefly
looked at the Java NIO implementation of ByteBuffer but in appears
that it is limited to primitive types. This problem space must be
common in systems that must interface with legacy devices whose
message interfaces are embodied in tightly packed byte based messages.
Are there any open source solutions in the Java space that attempts to
solve this problem so that we do not have to re-invent the wheel ???




==========================================================================
TOPIC: java.net.SocketException: Insufficient buffer space
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c9c56b240ed60b1
==========================================================================

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

Jeff wrote:

> "John C. Bollinger" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
>>I wrote:
>>
>>>wasting memory.  Unless you can determine the message size before 
>>>allocating the buffer, you have an unavoidable space / speed tradeoff 
>>>going on here.
>>
>>Which is true as far as it goes, but upon further reflection I realize 
>>that if the typical message is considerably smaller than the largest 
>>possible message, and if there are a lot of messages, then the time to 
>>allocate (and later GC) a large amount of unused buffer space many times 
>>may trump the time it takes to copy bytes around in a scheme that uses a 
>>smaller buffer by default and expands it as necessary for large messages. 
>>Such an adaptation scheme could be incorporated into my example code, but 
>>I'll spare you the details.
>>
>>This all comes back around to the point that you need to _test_ to 
>>determine where your performance problems are, and you need to _test_ to 
>>determine whether any hand optimization you come up with actually improves 
>>performance.
>>
>>
>>John Bollinger
>>[EMAIL PROTECTED]
> 
> 
> We deal with the variable message size by sending/reading a fixed length 
> header which contains the message size.  Then we allocate a buffer of that 
> message size and read the rest of the message.
> 
> We did get rid of BufferedInputStream based on this newsgroup's input.  The 
> application runs much faster.  Using one of our basic load tests, the 
> application runs 3x faster.  Clearly the BufferedInputStream was a 
> bottleneck.  It also seems to have eliminated the bug that started this 
> thread, but we need more testing to verify that.

I'm glad things are working better now.  I posit, however, that the 
underlying problem has not been solved, but rather that the application 
is now fast enough that the underlying problem does not manifest.  That 
may be sufficient for your purposes.

> John's read loop was much better than my old one so I swapped his in, with a 
> few adaptions. Here it is.
> 
> // assume we've read the message header and determined the msgLength
> msgBuffer = new byte[msgLength];
>  bytesRead = 0;
> 
>  for ( int numRead = inputStream.read( msgBuffer ,  bytesRead , 
> msgBuffer.length -  bytesRead );
> numRead > 0;
> numRead = inputStream.read( msgBuffer ,  bytesRead , msgBuffer.length - 
> bytesRead ) )
>                     {
>                         if ( numRead == -1 ) {         // I need to call a 
> clean up method if the probe sends -1
>                             finalize( "bytes Read = -1" );
>                         } else  bytesRead += numRead;
>                     }

Looks like a pretty straightforward adaptation.  One style comment: I 
dislike the use of the name "finalize" for your cleanup method, as it 
might cause confusion (to a human) with the no-arg finalize method 
inherited from Object.  That method has special semantics with regard to 
GC, and although the VM will not have a problem distinguishing between 
the two, future maintainers of the code might.


John Bollinger
[EMAIL PROTECTED]




==========================================================================
TOPIC: Classes SSH-SCP for Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b78404f5308632ce
==========================================================================

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

> I am searching for classes to use SCP (server use SSH2) in my Java
> application.
> Any idea ? Any link ?

OK, precisions : I need SSH2 implementation .... All I have found on the WEB
are implenting SSH1.

Xavier





== 2 of 2 ==
Date:   Fri,   Nov 5 2004 6:00 am
From: Michael Borgwardt <[EMAIL PROTECTED]> 

Xavier wrote:

>>I am searching for classes to use SCP (server use SSH2) in my Java
>>application.
>>Any idea ? Any link ?
> 
> 
> OK, precisions : I need SSH2 implementation .... All I have found on the WEB
> are implenting SSH1.

http://www.google.com/search?q=java+ssh2
Seems to give one as the first result, namely
http://www.jcraft.com/jsch/




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

== 1 of 3 ==
Date:   Fri,   Nov 5 2004 7:03 am
From: Ao <[EMAIL PROTECTED]> 

Hi everybody,

when closing my program I would like to start a Thread which does some 
cleaning up in the background, but opf course before exiting I need to 
be sure, that this Thread has finished running...

How can I wait for that Thread to finish, the following code does work, 
but freezes my UI...

...
private boolean cleanedUp = false;

...
public void programmBeenden() {
   Thread cleaner = new Thread() {
     public void run() {
       // clean up some things...
       cleanedUp=true;
     }
   }
   cleaner.start();

   // ... do some other stuff
   // finally wait for cleaner to finish
   while(!cleanedUp) {
     try {
       Thread.sleep(100);
     } catch(InterruptedExecption iuE) {}
   }

   System.exit(0);
}


What else can I do to make sure that cleaner has finished without 
freezing my UI.

Thanks, Aloys



== 2 of 3 ==
Date:   Fri,   Nov 5 2004 7:32 am
From: "[EMAIL PROTECTED]" <[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.




== 3 of 3 ==
Date:   Fri,   Nov 5 2004 7:31 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

Please post to one group only. Your question is not that important.

Ao wrote:
> How can I wait for that Thread to finish, the following code does work, 
> but freezes my UI...

There is some information about this in the comp.lang.java.gui FAQ. You 
are blocking the EDT.

Maybe you also want to read about shutdown hooks, SwingWorker and the 
Swing threading model in general.

Regarding the problem of waiting for a thread: Thread.join();

/Thomas




==========================================================================
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 2 ==
Date:   Fri,   Nov 5 2004 7:27 am
From: [EMAIL PROTECTED] (Paul  Smith) 

I have 3 questions in this post that I would be most grateful for some
help with.

I want to start a process that has its input sourced from a file. I
tried:

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

but I get a usage error returned, even though running the same command
from a command prompt is fine.
The problem appears to surround the redirection of standard input
(i've tried putting a backslash in front of it).

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

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.

QUESTION 2 -- Are there any other alternatives to the workaround
below?
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();
}



== 2 of 2 ==
Date:   Fri,   Nov 5 2004 7:51 am
From: bugbear <[EMAIL PROTECTED]> 

Paul Smith wrote:
> I have 3 questions in this post that I would be most grateful for some
> help with.
> 
> I want to start a process that has its input sourced from a file. I
> tried:
> 
> Process process = Runtime.getRuntime().exec("c:\mysql\bin\mysql.exe
> --database=bob < c:\file.sql"

Well, those backslashes in your string aren't going to help...

     BugBear



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

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