Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Question about NetBeans and error.printStackTrace();  (Read 572 times)
0 Members and 1 Guest are viewing this topic.
Offline tyeeeee1
« Posted 2013-05-14 20:16:03 »

I've noticed for a while, but never paid any mind, that NetBeans always wants to replace:
1  
 error.printStackTrace();


with:
1  
 Logger.getLogger(ResourceHandler.class.getName()).log(Level.SEVERE, null, ex);


Why does NetBeans do this and what does Logger do that printStackTrace() doesn't? In the class I took we were always told to use error.printStackTrace(); and Logger was never once mentioned.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #1 - Posted 2013-05-14 20:37:08 »

I'll be honest I have no real clue as I've never used it, but use `printStackTrace()` for the obvious reason; it shows you exactly where the error is. Logger I believe doesn't do this, but again I've never used it so I have no idea.

Online Danny02
« Reply #2 - Posted 2013-05-14 21:23:46 »

It's just a normal warning, because you should not print to the standard output(console) from production code.

Everybody uses System.out.println and printStacktrace because they are good tools while developing, but the warnings are good too, because they remind you to get rid of these calls before releasing your code.

The replacement which netbeans gives you uses the standard Java logging classes. They are quite basic and work, but especially when you are creating libs use  slf4j. When you don't know what logging is for, google yourself some nice tutorials Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Andre Lopes
« Reply #3 - Posted 2013-05-14 21:59:52 »

It's just a normal warning, because you should not print to the standard output(console) from production code.

Everybody uses System.out.println and printStacktrace because they are good tools while developing, but the warnings are good too, because they remind you to get rid of these calls before releasing your code.

The replacement which netbeans gives you uses the standard Java logging classes. They are quite basic and work, but especially when you are creating libs use  slf4j. When you don't know what logging is for, google yourself some nice tutorials Smiley

Or maybe log4J
But, yes , you should pay attention to netbeans warning, they teach you some stuff, like , for example, i didnt know about diamond operator.
Offline tyeeeee1
« Reply #4 - Posted 2013-05-14 22:00:36 »

I'll take a look at slf4j then. If you leave code that prints to a console in production code, does anything bad happen?
Offline Andre Lopes
« Reply #5 - Posted 2013-05-14 22:18:15 »

Not really. Just be sure to remove when you release the "final" product Tongue
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #6 - Posted 2013-05-14 23:01:44 »

It doesn't even really matter in the final product, but it's useless code since the user can't see it (unless running from cmd). However, it may slow down your game if you are printing many times or many different things (incrementing/decrementing numbers, etc., will slow it down a lot).
Offline quew8

JGO Coder


Medals: 29



« Reply #7 - Posted 2013-05-15 20:03:29 »

The other thing is that you think you're telling the user an error has occurred but they actually have no idea. There is very little that is more annoying.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (23 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!