problem with reading stdout from a child process under jdk-1.1.6
Hi all,
I encountered a problem when I start a prog from my
java-prog and
try to get the stdout or stderr.
The problem is, that I wrote the code with jdk-1.1.3,
changed my
system to Redhat 5.1 (with glibc) and jdk-1.1.6 and now it
doesn't
work anymore. As long as stdout is empty there are no
problems
but when the prog tries to read the messages it simply
hangs.
To make myself a bit clearer, here is the code:
..
Process process1;
String msg=new String();
Runtime run1=Runtime.getRuntime();
try {
process1=run1.exec(command);
InputStream in=process1.getInputStream();
BufferedReader in_read=new BufferedReader(new
InputStreamReader(in));
// it's happening here:
while((msg=in_read.readLine()) != null){
System.out.println(msg);
}
Hope somebody knows a solution for that.
Thanks in advance
Mark
Re: Example of CardLayout.....
[EMAIL PROTECTED] wrote: > Please, send a example of CardLayout using model event of JDK 1.1 > Sorry, for my english.. > Thank you. Hi, try out the java-tutorial available at the java homepage http://java.sun.com It covers almost everything one can do with Java enjoy Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880
Re: Interprocess Communication with a Java Application
Hi all, chris roffler wrote: > Why do you want to go through all this trouble ? > > Why don't you just use Voyager from ObjectSpace www.objectspace.com > > Chris Well, I am using voyager AND java sockets just because I need to connect to native code and don't want to run a CORBA server. And it really was no trouble at all to implement it! For the Java sockets there is a rather nice example in the Java Tutorial and under C++ it's also no problem, there are enough tools out there to build sockets. I think my co-worker used Borld C++ Builder, for him it was just a matter of drag an drop, and for me more or less just copy and paste ;-) So, again, it's really no trouble, and socket communication is also quite fast, at least for my purpose ... enjoy Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880 > > > -Original Message- > From:Michael.Sinz [SMTP:[EMAIL PROTECTED]] > Sent:Friday, October 23, 1998 2:04 PM > To: java-linux; steve > Cc: Michael.Sinz; norm > Subject: Re: Interprocess Communication with a Java Application > > On Fri, 23 Oct 1998 10:03:56 -0700, Steve Bankes wrote: > > > > >I am seeking advice about interprocess communication between a > Java application > >and other, not necessarily Java, applications. > > > >I am developing the Java application under Linux but want to be > able to run it > >under Windows. So far I have been using Linux FIFO's (named > pipes) rather than > >sockets. I am using FIFO's because it is easier to write shell > scripts that > >will create, read from and write to FIFO's than for sockets, and > because there > >does not seem to be a Java internal socket; i.e there seems to be > no Java analog > >of AF_UNIX (UNIX internal protocols) sockets. > > > >So far this approach is working fine under Linux. I know nothing > about Widows > >or Windows programming. I am concerned how portable this will be > to Windows. > > The only real IPC in Java that is platform independant is via the > network > I/O classes. This also happens to work rather well between > machines, not > just between processes. Now, it is not light weight. > > Windows NT has a think known as a "named pipe" the is much like a > fifo. > However, it requires special code to create/manage one. > Connecting to > one (being sender usually) is trivial and even works over the > network > from Windows 95 and Windows 98. However, the other end requires > NT. > > Again, sockets or UDP are very handy and with 127.0.0.1 it even > should work > reasonably fast. (Loopback address) And, it is easy (or at least > easier) > to work over the network to systems of different platforms even. > I do this > a lot with normal sockets and RMI and serialization. (All three > in one > program even, but usuaully just sockets since that works almost > everywhere) > > Michael Sinz -- Director of Research & Development, NextBus Inc. > mailto:[EMAIL PROTECTED] - http://www.nextbus.com > My place on the web ---> http://www.users.fast.net/~michael_sinz > >
wanted:java linux to win linux FAQ
Hi all, is there a list or FAQ for things that you should take care of when you want to run your java software on both Linux and NT ?? I ran into some small probs. when I ran my programs - which I developed under Linux - on Win NT. For example, I can iconify the frame under Linux (KDE) but not under NT. Also, FileWriter seems to behave differently under NT, that line out=new PrintWriter(new BufferedWriter(new FileWriter(dataFile))); seems not to do the same on both systems. It didn't work with NT. I changed the line to out=new PrintWriter(new OutputStreamWriter(new FileOutputStream(filename))); voila, it works. But anyway, where is the FAQ, there are more little things especially with the awt, that I like to change Thanks Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880
Retrieving a fully qualified hostname under NT
Hi all, I've posted that question a few days ago to java.lang.programmer but got no response :-( But, since this problem is really bugging me, and there might be some people in this list that run there progs under NT and Linux, just as me, I hope to find a solution here. Anyway, here is the problem, easy and simple when I use String localhostname=(InetAddress.getLocalHost()).getHostName(); under Linux I get the fully qualified hostname, under NT just the local hostname, eg. host instead of host.my.domain.com Our admin says that its an NT feature/problem (you never know) because it stores both names separately and returns usually only the local hostname. Is there a workaround for that, so I can get the fully qualyfied hostname or do I just have to live with that? Or even better is our system misconfigured and I can tell our admin that he's wrong (which is always fun ;-) ) Thanks in advance Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880
Re: [Java-Linux] about this list ...
Hi .. olivier Dulac wrote: > Hi, > > Sorry for this isn't a java-related message, but it a few suggestions > about the list itself, and people using it... > > 1) include [Java-linux] in your Subject:, for every mails to this list > >*please* put a header in front of every email for the mailing list >(exemple: "Subject: [Java-linux]". >it can be a good idea to put exactly this [Java-linux], because if >everyone include his own prefix, it won't be usefull anymore ;^) > >It's usefull to be able to seprate mails from the list from >mail from other sources... especially when there is so much emails! Er ... mmm. what about email filters? What sort of email software are you using?? In which way, just set the filter to sender = java-linux, c'est ca .. Personally, I think the error is on your side :^| >I will try to find where to post this mail to touch the people >in charge of this mailing-list, but meanwile please do this yourself, >it isn't difficult , takes only 2 secondes, and will be a great >enhancement :^) > > 2) about included messages: > >I also want to ask everyone there to *please* skip all the irrelevant >when they include a message for a reply... sound nice, but how are you going to define "irrelevant", e.g. which part of your message should I leave out ?? Usually I delete a message which contains just a question that I can't answer (so basically all ;-) ) and just keep the replies, thats why it is so nice to have the original message included. I don't want to know what the discussion was about, I want to know what the question reply was, because I can't remember every posting when I look for answers a couple of weeks later. >Most of the time just 2 or 3 lines are enough (and are >recommended, because it helps people without the original message to >see what the discussion is about...) but you *never* need to include >the entire message (especially the signature)... >(the worst exemple beeing people including a *huge* [and very recent!] >spam article just to complain against spam! Quite funny ;^) and it >looks like those messages preventing a lot of people against fake >"virus in this email" messages, and (re)sended to so many people than >they become a form of virus themselves! (or, more "acurately", a spam)) > >This is especially ennoyant for people over a slow modem connection... >They spend time (and so money) to download their emails... I know, but some things you just have to live with it seems. > >Mailing lists are usefull, but can become unusable if the >"noise/signal" ratio become to high... > > Thanks in advance... :^) > (And i hope i won't be flamed, these are only my opinions after all... ;^) I didn't flame I think, if it sounds like, it's just _my_ opinion Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880
Re: Retrieving a fully qualified hostname under NT
Thanks alot for your help, looks like we've found something which isn't really write-once-run-everywhere like ... I don't like to implement something just because the java-port for a particular OS does NOT do what it should (according to the java-doc getHostName() retrieves the FQHN). For me, this behavior of NT shows at least one of those two things: a) NT is not a _real_ OS b) M$ doesn't like Java (or is Sun doing the port for NT ??) But this belongs to a different list Mark
Re: Runtime.exec ()
Hi,
I tried the same thing some time ago.
The problem is, exec works, for example if you try exec("ls") you wont get
problems. However, running anything as a command that has a
redirection of out-/ input in it fails.
I don't know why, but that's what I experienced.
Anybody knows why ???
Mark
Marius Schamschula wrote:
> Hi there,
>
> I am having trouble getting Runtime.exec () to do anything (yes I do send
> the desired command as an argument...e.g. "/bin/ls /home/someusr/dir >
> /home/someusr/test"). I've tested my code on both a mkLinux (DR2.1u5) and
> Debian Linux machine running various flavors of JDK 1.1.x. I'm trying to use
> Java to directly invoke various shell scripts. I do a waitFor () for the
> process to terminate, check the InputStream and ErrorStream. The streams are
> empty...
>
> Any hints?
>
> TIA
>
> Marius
>
> Marius Schamschula, optical physicist, mac, and network coordinator
>
> The Center for Applied Optical Sciences: http://www.caos.aamu.edu/
> Department of Physics, Alabama A & M University
--
M a r k H o f m a n n
Department of Computer Science
University of Stellenbosch / South Africa
phone: +27-82-7449880
Getting off the list [was Re: How to invoke ?]
[EMAIL PROTECTED] wrote: > How do i get off this list? The place where I heard about this list is http://www.blackdown.org/java-linux.html And that's where they also tell you how to get off the list ... By the way, by entering the keywords +"java-linux" +mailinglist +unsubscribe in www.yahoo.com I found the following URL http://summer.snu.ac.kr/~djshin/linux/mail-list/ which contains of mailinglists for linux. And it has buttons that one can click subscribe or unsubscribe from those mailinglists. Easy to find the site ... One has just to look for it Mark -- M a r k H o f m a n n Department of Computer Science University of Stellenbosch / South Africa phone: +27-82-7449880
