Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't the editor have global search & replace?
 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you expect to remove something from the source code without changing the source code?
 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • 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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • 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
 
Maneesh Godbole
Saloon Keeper
Posts: 11185
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12198
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perl or AWK could do it in just a few lines.
 
vipul bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • 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 Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
That's easy: Regexp search/replace

Thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • 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 bondugula
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic