• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to Remove System.out.println() in my Application Code

 
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I have to remove System.out.println()'s in my total application.Is there any tool to remove all the System.out.println()'s...

I am using Jdeveloper tool.

Thanks In Advance,
Vipul Kumar.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doesn't the editor have global search & replace?
 
vipul John
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf Dittmer,

Thanks For your Reply.I haven't checked global search.I am using Microsoft visual source safe as confiuration management. I cannot global search and replace as i have to checkout each file and then remove System.out.println()'s..Is there any alternative to find System.out.println()'s in the application code...

Thanks In Advance,
Vipul Kumar.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you expect to remove something from the source code without changing the source code?
 
vipul John
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I don't mean that.

Doesn't the editor have global search & replace?



Your suggestion is good one. I can global search and replace the code if iam not using the configuration management.I cannot replace the code directly.I have to check in each file and then replace.It takes minimum 4-5 days to replace the code.Please suggest me another alternative...

Any way Thanks for your reply..

Thanks & Regards,
Vipul Kumar.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vipul bondugula wrote:Please suggest me another alternative...


It is hard to suggest an alternate! you can write your own program to search and remove the System.out.println() in your source files.
but again you need to test the program in different test cases thoroughly! writing the tedious test case and testing may take 4 or 5 days
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It takes minimum 4-5 days to replace the code


I am not really sure understand what you mean here. I am using eclipse and I just searched for logger statements in my code. I got around 1327 hits in a few seconds.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote: I am using eclipse and I just searched for logger statements in my code. I got around 1327 hits in a few seconds.


vipul dont have this facility in his work environment!

even in eclipse, searching System.out.println statement and replacing/removing is not that easy, for example
System.out.println("Logged Exception : "+e.getMaessage); you can highlight System.our.println, but what would happen to remaining strings! however you can replace System.out.println with // but still commented part remains in code!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Seetharaman Venkatasamy wrote:you can highlight System.our.println, but what would happen to remaining strings! however you can replace System.out.println with // but still commented part remains in code!


That's easy: Regexp search/replace - every decent editor and IDE has it.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perl or AWK could do it in just a few lines.
 
vipul John
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks For Your Replies.

In the global search iam having regular expression option.can anyone provide me search keyword to search System.out.println() statements. Actually i have provided "System.out.println(" but this does not work.Showing Regular Expression Error.

Thanks & Regards,
Vipul Kumar.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:
That's easy: Regexp search/replace


Thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vipul bondugula wrote:Thanks For Your Replies.
can anyone provide me search keyword to search System.out.println() statements.



try this: System\.out\.print.*
 
vipul John
Ranch Hand
Posts: 253
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Seetharaman,

search keyword works fine.5779 System.out.println() statements out of 5260 files.

Now my team had to work a lot.check in files from server and remove..

Thank you once again..
Vipul Kumar.
 
Sheriff
Posts: 22857
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a lesson for next time, you should probably use a logging framework (e.g. Log4J, SLF4J, etc) instead of using System.out. That way you can increase the logging level (to debug for instance) when testing, and decrease it again (to info / warning) when deploying to production.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic