Cant view System.out.println messages

984 views
Skip to first unread message

Gabriel Gutierrez

unread,
Sep 28, 2007, 6:06:41 PM9/28/07
to Google Web Toolkit
Hi, i'm trying to print something to the server console, but i can't
see it, i try to create like a "log" file and when it is compiling, it
says that java.io.RandomAccessFile or any of java.oi can not be
resolved to a type.


Any ideas why? i'm using Netbeans 5.5.1 and i tried with the bundle
tomcat4 and tomcat 5.5 and glassfish and the error is the same

Thanks,

Peter Blazejewicz

unread,
Sep 28, 2007, 7:10:54 PM9/28/07
to Google Web Toolkit
hi Gabriel,
as in Eclipse System.out.* should go within IDE out window in NetBeans
I think. You shouldn't see anything in GWT shell console but within
IDE, You cannot add any non-ported SDK parts to your GWT application
client module,
regards,
Peter

Gabriel Gutierrez

unread,
Sep 29, 2007, 9:54:36 AM9/29/07
to Google Web Toolkit
why not ? i mean i want to do some debuggin, there should be a way
that i can see some output, if not, it's worthless to use this
framework, i dont think people code all at once, there should be a way
where i can see the outputs (file, console, whatever) if not, they
should start thinking a way to do it, because its very important whe
you want to trace something.

Thanks,


On 28 sep, 18:10, Peter Blazejewicz <peter.blazejew...@gmail.com>
wrote:

Adam T

unread,
Sep 29, 2007, 11:13:39 AM9/29/07
to Google Web Toolkit
Gabriel,

As Peter says, you can't use System.out in your final application - it
is not part of the emulated library, and doesn't really make sense to
make it so; where would JavaScript application running in a browser
write too?

The power of GWT is in that you can perform your development and
debugging in an IDE. Use the power of Netbeans/Eclipse/whatever IDE
to support your debugging rather than relying on system.outs.

If you feel you have to use system.out then that will only work in
hosted mode and your output will more than likely go to the IDEs
console (it certainly will not go to the hosted mode console) and
will, as you see break when you try and compile. To get output on the
hosted mode console use the GWT.log("your message here",null)
approach; but again this only works in hosted mode since all GWT.log()
calls will be dropped by the compiler.

If, as a last resort, you really really need to see "system.out" in
web mode (i.e. after you have compiled the code to JavaScript), then
you need to look into using a JavaScript logger and wrapping it with
JSNI, or search on this forum, maybe someone has done it for you.

My advice would be to rethink any debugging strategy and learn to use
your IDE's built in tools that will show you all the output you should
need rather than trying to use system.out.

//Adam

Reinier Zwitserloot

unread,
Sep 29, 2007, 12:50:02 PM9/29/07
to Google Web Toolkit
System.out.println does NOTHING in script mode, and prints to the
console (and not the GWT window) during hosted mode.

GWT.log() does nothing in script mode, and prints to the GWT window
during hosted mode.

If you want script-mode debugging, I suggest checking out firelog:
http://zwitserloot.com/tipit-gwtlib/example

werda...@gmail.com

unread,
Sep 29, 2007, 6:12:55 PM9/29/07
to Google Web Toolkit
Hi Peter,

If you want to trace something in hosted mode I suggest you use the
debugger within your ide rather than debug statements. It is a very
handy tool and allows you to step through the java code you have
written and displays the results in the hosted browser.

If you want more help on this feel free to email me.

Cheers

MC

Gabriel Gutierrez

unread,
Sep 30, 2007, 11:23:28 AM9/30/07
to Google Web Toolkit
Sorry for the late, i havent had the time to read, ok so...
System.out.* is out of game; what i want is to see some output, of any
kind, i've tried using Log4j and the and java.io.PrintWriter but it
crashed i guess is for all this that you explained about hosted mode,
what i would like to know is way to write/show anything to any parte
of the server (by console, file, email, U.F.O. or wahtever) so i can
keep the track for a pice of code.

I checked the URL that Reinier posted, but i dindt understant the app.

I'm gonna try the GWT.log to see what happend, because one of you say
that i can use GWT and the other said that i can't and i dont really
understand about hosted mode and script mode, im a newbe here lol, so
i would like to try everything that you suggest.

Thanks for the responses.

On 29 sep, 17:12, "werdafuc...@gmail.com" <werdafuc...@gmail.com>
wrote:

Adam T

unread,
Sep 30, 2007, 11:50:47 AM9/30/07
to Google Web Toolkit

>
> I'm gonna try the GWT.log to see what happend, because one of you say
> that i can use GWT and the other said that i can't and i dont really
> understand about hosted mode and script mode, im a newbe here lol, so
> i would like to try everything that you suggest.
>

GWT.log will only work in Hosted mode (which is where you are
executing the java code through the GWT console - you'll know if you
are in this mode as you get two windows; one a console and one your
application running with a GWT logo in the top right). Any messages
will appear in the Hosted mode console, but you don't get much control
on granularity (i.e. it is not helpful like Log4J; with GWT.log() you
get all messages).

Once you compile your code into JavaScript you enter "web mode" (or
script mode as you say) where GWT.log will be compiled out - since you
can't write anything to file systems from JavaScript code (this
inability of JavaScript to write to file systems is the issue that
also stops System.out and java.io from working).

Reinier, I think, linked you to some code he has that allows a GWT
application to link to the FireBug tool in case you really want to
send out debug messages in the compiled code. I'm sure he can explain
what it does and how to use it if you need.

It still sounds though that you might benefit from using an IDE
debugger, where you say "keep track of a piece of code", that is
exactly what the IDE debugger will do for you; allowing you to suspend
code, step through code, examine variables etc.

Good Luck!

//Adam

Reinier Zwitserloot

unread,
Sep 30, 2007, 12:21:58 PM9/30/07
to Google Web Toolkit
FireLog allows you to log with FireBug. You'll have to read up on
FireBug (and FireBug-lite) to know what that does. FireLog wraps the
firebug system calls into java (1) and automatically loads firebug-
lite only on an as-needed basis (2), that's all it does.

Gabriel Gutierrez

unread,
Oct 1, 2007, 10:43:57 AM10/1/07
to Google Web Toolkit
Hi guys, i tried the GWT.log() and it didn't work (well i guess it
worked, but i didnt see any output), but i guess i know why, this app.
that you talk about the logo at the top right, is the benchmark app
from google right? if it is, i haven't use it yet. i saw once i didn't
understand what's for.

Well im gonna try the FireLog thing scince i have it install shouldn't
be difficult to see what happen

My apologies for been too much dummy, i've been working with GWT like
2 weeks, and i haven't had the time to read about it, i just got the
framework and start using it.

Thanks for the support.

Reply all
Reply to author
Forward
0 new messages