I am compiling a java program from a Dos prompt under Windows98. (Ex: javac TestProgram.java) I have numerous error messages. Errors at the top of the program scroll off the Dos prompt screen. I can only view the errors that are further down in the program. Is there a trick for capturing the messages to a file? I have tried "piping" the errors to a file without it working. (Ex: javac TestProgram.java > holdErrors.txt) I know if I went to an IDE environment, like JBuilder 4, it would hold my error messages in one of its windows. But, I am learning java and preparing for the Certification exam. On advise from others at the "ranch", they have recommended against using it. Thanks.
Textpad is a pretty decent editor that captures the compiler error messages in its GUI. You can even double click on the error message to go to the offending line.
make your DOS window bigger right click on the title bar - and click on properties..
rani bedi
Ranch Hand
Joined: Feb 06, 2001
Posts: 358
posted
0
Add the scroll bars to your Dos Window. 1. Right click on the title bar. 2. Click properties. 3. Increase the buffer size and the window size according to your needs.
">" pipes from the output stream, "2>" pipes from the error stream... ( Remember System.out and System.err... that is why they exist seperatly... there are two different streams... )
HTH, -Nate
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Let's see . . . WHO invented DOS??? Oh Yeah THAT company. "2>" now THAT'S intuitive . But thanks for both tips guys. I always thought it was irritating too.
"JavaRanch, where the deer and the Certified play" - David O'Meara
The standard I/O channels were assigned numbers : 0 - standard input 1 - standard output 2 - standard error
These were primarily used in Unix system programming, but in this one way it crept into user commands... I guess the same syntax was used in DOS because they couldn't think of another way to signify the error stream...
So... unfortunately... we can't bash Microsoft for it...
-Nate
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
And does UNIX use the "2>" command for piping?
Scott Matthews
Ranch Hand
Joined: Jun 28, 2001
Posts: 36
posted
0
I tried the suggested: javac TestProgram.java 2> holdErrors.txt and I got the javac.exe utility complaining that it did not like the command line arguments. I got the same screen as if I had typed javac by itself. (The option/paramater screen for the javac.exe utility)
[This message has been edited by Scott Matthews (edited July 10, 2001).] [This message has been edited by Scott Matthews (edited July 10, 2001).]
Cindy- Yes! Well... sh ( and most of it's derivatives ) use this... but some other shells ( notably csh ) do different things... ( csh uses >& to redirect stdout and stderr to a file... strangely enough, it doesn't provide a way to redirect only stderr... )
Scott- Hmmm... Just to make sure, I tried this just now at work on my Windows NT machine, and on my Solaris box... this worked on both of them...
I looked up javac in the Sun documentation and came up with this... The old version of javac supported a command line argument to redirect output from stderr to stdout... for some reason the new version of javac does not support this... I even found a bug report on Sun's site that mentions needing this option because it is "useful under win32 due to shell inadequacies"... Hmmm... wonder if this is your problem?
Anyway... this may work...
I am not sure what the ramifications of using the old compiler would be... but tell us if this works...
By the way... when I got home, I tested this out on my Win98 computer... sure enough! Windows 98 doesn't support the 2> redirect! I wonder why? WinNT supports it, and I am pretty sure that older versions of DOS ( and perhaps Win95? I don't remember... ) used it too...
So, I guess we can blame M$ for this one at least, eh Cindy?
I am not sure if the 'oldjavac' fix I gave above works on Win98... I only had java 1.2 installed on my Win98 computer... it only came with the new version of javac that doesn't have the -Xstdout parameter... I think it shipped with Java 1.3...
Oh, well... If that doesn't work then I guess you could follow Fred's suggestion above and change the properties of the DOS window so it will let you scroll back...
-Nate
Roy Tock
Ranch Hand
Joined: Jul 16, 2001
Posts: 83
posted
0
Microsoft OS's based on DOS haven't had built in capability to redirect stderr for as long as I can remember. It's been a real pain in the side for me. If you're *ambitious*, and you've got a Windows C compiler such as MSVC++, and you can decipher Microsoft's developer documentation, you might be able to build yourself a program that will redirect stderr. Here's a starting point: http://support.microsoft.com/support/kb/articles/Q190/3/51.ASP Good luck.
Roy Tock
Ranch Hand
Joined: Jul 16, 2001
Posts: 83
posted
0
As it turns out...there might be an easier way. In the advanced forum, Jim Yingst posted the link http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html as an answer to a reader's question about how to execute a DOS command in Java. (Link to the topic: http://www.javaranch.com/ubb/Forum34/HTML/001180.html ) The same link hints at a way to capture Win9x DOS stdout in Java! Search for the string "Windows 98" in the article to see the hint. I haven't tried it myself, but it doesn't seem like a difficult exercise. If you have time to implement it, be sure to post the solution here; I'd be curious.
karl koch
Ranch Hand
Joined: May 25, 2001
Posts: 388
posted
0
hi, just use a tool as UltraEdit to do this. you can capture outputs to the editor window. karl
Judy Herilla
Ranch Hand
Joined: Jan 05, 2001
Posts: 89
posted
0
Click the dos icon in the top left...choose properties...set the buffer to a high number, 1000 or so...and then choose modify shortcut. Runt he command again.
SCPJ2
Terence Doyle
Ranch Hand
Joined: May 30, 2001
Posts: 328
posted
0
HI, Nathan: Your solution works on my W98 usind JDK 1.3 This will be very useful as I generally get a few screens worth of errors Terry
Raising Flares debut album 'Ignition' out now
http://www.raisingflares.com
Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Bill Norton
Greenhorn
Joined: Mar 29, 2001
Posts: 27
posted
0
There are two types of DOS prompts under Windows NT, command and cmd. Under Windows 9x there is only one, command.com. command does not give you the ability to change the buffer size if she is using Win98 this is not an option for her. MS added alot of Unix-ish funtionality to NT's DOS prompt(cmd) but hasn't to Windows 9x(command). I.E. under Windows NT you could type cd prog* and this should take you to c:\program files under 9x this will not work. My guess is that MS wants to push _ANY_ development type work to NT and therefore hinders 9x functionality. Or they don;t believe anyone using 9x would need this type of command line power. Also, I don't believe>2 will work under 9x also. Hope this helps, Bill Norton
zaeem masood ashar
Ranch Hand
Joined: Mar 17, 2001
Posts: 54
posted
0
Hi, A workaround.......quickly press the "pause" key on your keyboard after pressing enter for javac. Keep pressing enter and pause to scroll down. Do i hear a UgggHHHhhh!!
------------------ SCJP2
SCJP2
Alvin Tan
Greenhorn
Joined: Jul 25, 2001
Posts: 17
posted
0
Originally posted by karl koch: hi, just use a tool as UltraEdit to do this. you can capture outputs to the editor window. karl
Hi Karl, How can we capture outputs using Ultraedit? Thanks.
Bill Norton
Greenhorn
Joined: Mar 29, 2001
Posts: 27
posted
0
I believe we have missed the easiest solution. Just write code that has no bugs. Bill
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Of COURSE! And you are here to lead the way . By all means share with us the tricks and techniques to do that. WE await your quidance "oh wise one".
Bill Norton
Greenhorn
Joined: Mar 29, 2001
Posts: 27
posted
0
Oh no, I am a consultant, I just tell you how to fix your problems I don't actually do it for you!! I did write a program that printed "Hello World!" the other day with no bugs. Proof of concept. Bill Norton