Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Valeyard
Mar 30, 2012


Grimey Drawer

qntm posted:

I don't know what java.util.Scanner is exactly but I'm guessing that sitting there apparently doing nothing while waiting for you to type something is exactly the correct behaviour for that program

wow, yes. I dumbed dumb the code to make it easier to ask about and then ended up confusing the process hanging for the actual intended result jesus that was dumb


but one more thing, right clicking the jar and saying open with Java Platform SE Binary really does do nothing! which is kind of annoying because the whole point of using the jar is to avoid starting it with that command anyway

Adbot
ADBOT LOVES YOU

gonadic io
Feb 16, 2011

>>=

qntm posted:

I don't know what java.util.Scanner is exactly but I'm guessing that sitting there apparently doing nothing while waiting for you to type something is exactly the correct behaviour for that program

Also this. The program should just echo input after you press enter each time.

C'mon Valeyard, the first rule of "my program isn't doing what I expect it to" is to loving pepper it with print statements.

and then wishing you had instead used a debugger

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Luigi Thirty posted:

sadly that doesn't work with ~metrics~

gotta spit the game to change the metrics

gonadic io
Feb 16, 2011

>>=
gently caress that's what I get for phone posting while waiting for the bus

Space Whale
Nov 6, 2014

gonadic io posted:

yeah but gaming metrics is still not about being a competent programmer

lol like programmers would min/max anything

like imagine if there was a career based on doing such things

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

Space Whale posted:

lol like programmers would min/max anything

like imagine if there was a career based on doing such things

i became a programmer because my dream job of being a gold framer in wow was unavailable to me (since i'm not asian)

leftist heap
Feb 28, 2013

Fun Shoe
valeyard i guess you're a beginner or whatever and this is the terrible programmer thread but did you even like, read your code and attempt to reason about it before posting it??

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

rrrrrrrrrrrt posted:

valeyard i guess you're a beginner or whatever and this is the terrible programmer thread but did you even like, read your code and attempt to reason about it before posting it??

valeyard is a bad poster for many reasons but i think he does his due diligence w/r/t posting in this thread

Corla Plankun
May 8, 2007

improve the lives of everyone
i've only seen a few of his posts but it seems pretty clear that he is just not an intelligent man

and i mean that objectively,not like an insult

Valeyard
Mar 30, 2012


Grimey Drawer
sorry. its a combination of being legit stupid sometimes and (very often) jumping to worse case and start shouting about stuff before realising whats really going on

MeruFM
Jul 27, 2010
you should talk to your senpai instead of random people on computerfunny

Luigi Thirty
Apr 30, 2006

Emergency confection port.

MeruFM posted:

you should talk to your senpai instead of random people on computerfunny

he's clearly frustrated that senpai
doesn't pay enough attention to him

tef
May 30, 2004

-> some l-system crap ->

Valeyard posted:

code:
import java.util.Scanner;

public class CLI {
	
		public CLI(){
		}
		
		public static void main(String args[]){
			boolean running = true;
			        Scanner s = new Scanner(System.in);
			        while(running){
			           String command = s.next();
			           System.out.println(command);
			        }
		}
}
so say I have something like this. i export it as a runnable jar (with eclipse), and then get a jar file that wont run. ive tried using command line and running:

java -jar testJar.jar

but nothing, the process just hangs. no errors, just nothing

moral:


although there are general purpose strategies for debugging things like this,

(i.e put print statements in everywhere. put them in bits you think are running, see where the print statements stop happening, or delete some code, or exit early, throw a specific error, to see if the program gets that far)

it is hard to know what a program is doing when you don't know what it is meant to be doing in the first place


welcome to the terrible programmers thread

brap
Aug 23, 2004

Grimey Drawer
jesus christ debuggers exist you don't have to write in print statements left and right

Jerry Bindle
May 16, 2003
Logger is good, use logger. you can turn it on and off without having to comment it out like printfs

make a shortcut for
code:
private static final Logger logger = Logger.getLogger(whatever.class.getName());
and plop one in every class

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

fleshweasel posted:

jesus christ debuggers exist you don't have to write in print statements left and right

gonadic io
Feb 16, 2011

>>=

Barnyard Protein posted:

code:
private static final Logger logger = Logger.getLogger(whatever.class.getName());

lmbo @ java

Soricidus
Oct 21, 2010
freedom-hating statist shill

Valeyard posted:

but one more thing, right clicking the jar and saying open with Java Platform SE Binary really does do nothing! which is kind of annoying because the whole point of using the jar is to avoid starting it with that command anyway
sounds like you're on windows. there are two Java binaries for windows, java.exe and javaw.exe. one of them is for console programs and the other is for gui programs. it sounds like you're using the wrong one, so try the other. maybe you could use a shortcut or batch file to launch it with the right one.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison

Soricidus posted:

sounds like you're on windows. there are two Java binaries for windows, java.exe and javaw.exe. one of them is for console programs and the other is for gui programs. it sounds like you're using the wrong one, so try the other. maybe you could use a shortcut or batch file to launch it with the right one.

it's this, the default jar association on windows is with the console application. write a batch script that invokes a new command window and runs your jar then waits for you to close it

alternately you can write a little gui code to create a UI and attach i/o to that

Notorious b.s.d.
Jan 25, 2003

by Reene

Soricidus posted:

sounds like you're on windows. there are two Java binaries for windows, java.exe and javaw.exe. one of them is for console programs and the other is for gui programs. it sounds like you're using the wrong one, so try the other. maybe you could use a shortcut or batch file to launch it with the right one.

lol windows

Space Whale
Nov 6, 2014
code:
private static final Logger logger = Logger.getLogger(whatever.class.getName());
HOLLA HOLLA logger getLogger

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



getloggerlogger getlogger

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

Barnyard Protein posted:

Logger is good, use logger. you can turn it on and off without having to comment it out like printfs

make a shortcut for
code:
private static final Logger logger = Logger.getLogger(whatever.class.getName());
and plop one in every class

this is the kind of garbage that makes pragmatic programmers look at java and say "you are dumb horseshit created to inflate LOC and source sizes" hth

Brain Candy
May 18, 2006

Jonny 290 posted:

this is the kind of garbage that makes pragmatic programmers look at java and say "you are dumb horseshit created to inflate LOC and source sizes" hth

what you can't see from all them words is that it only takes typing 'logger' then pressing Alt+Enter to make that

if you write java/C# in gedit, well, that's your problem

Brain Candy
May 18, 2006

also lol at a guy who only writes in p-langs calling himself 'pragmatic'

leftist heap
Feb 28, 2013

Fun Shoe
why use the class name when you can use the class object itself though

code:
private static final Logger LOG = Logger.getLogger(ThisObject.class)
pretty gd benign thing to complain about. people complain about the dumbest poo poo in java when there are tons of legit complaints. if that's too much boilerplate for you to use an insanely robust and useful logging library then i don't really know what to say.

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

Brain Candy posted:

also lol at a guy who only writes in p-langs calling himself 'pragmatic'

oh ho let me get wound up and defend myself here!



lol eat rear end

Cybernetic Vermin
Apr 18, 2005

hide this somewhere and assume no one will notice

code:
public Log {
    public static error(String s) {
        Logger.getLogger(Thread.getCurrentThread().getStackTrace()[1].getClassName()).error(s);
    }
}

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

are you sure that's expensive enough?

Necc0
Jun 30, 2005

by exmarx
Broken Cake

Jonny 290 posted:

this is the kind of garbage that makes pragmatic programmers look at java and say "you are dumb horseshit created to inflate LOC and source sizes" hth

lol at caring about source code size ityool 2015

Notorious b.s.d.
Jan 25, 2003

by Reene

rrrrrrrrrrrt posted:

why use the class name when you can use the class object itself though

older versions of log4j only took a string argument

Cybernetic Vermin
Apr 18, 2005

Subjunctive posted:

are you sure that's expensive enough?

adding an extra line and member to every class in the system to optimize performance is pretty expensive in its own way, and it would be pretty trivial to selectively reverse if performance actually became an issue

i don't really suggest that though, clearly the correct solution is to write an Instrumentation agent which injects bytecode into the Object class to add a logger member and construction to its constructor: no performance hit, no clutter!

Brain Candy
May 18, 2006

Jonny 290 posted:

oh ho let me get wound up and defend myself here!



lol eat rear end

or you could stop saying dumb poo poo that betrays your limited experience

bit of irony coming from me, but hey

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
rear end eating's still on the table tho

Brain Candy
May 18, 2006

txt me

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Jonny 290 posted:

this is the kind of garbage that makes pragmatic programmers look at java and say "you are dumb horseshit created to inflate LOC and source sizes" hth

yeah but honestly who gives a poo poo because 90% of it gets autocompleted and you can tell instantly what it's supposed to do when you look at it

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

Luigi Thirty posted:

yeah i know i'm fine but it's my first actual computer job (even if it's glorified computer janitoring) and i don't want to mess it up! from what i read they want you to work at an impossibly fast pace and throw you out on your rear end in 6 months if you can't.

its awesome how you have only been at this for a short time yet you sound like a seasoned pro now

Cybernetic Vermin
Apr 18, 2005

Blinkz0rz posted:

yeah but honestly who gives a poo poo because 90% of it gets autocompleted and you can tell instantly what it's supposed to do when you look at it

entirely meaningless clutter carrying the possibility that one of the 30,000 copies of the line is wrong somewhere (one obvious case being that the wrong class is sent and things don't get filtered as expected)

FamDav
Mar 29, 2008
i just annotate my classes with @Log

Adbot
ADBOT LOVES YOU

Jerry Bindle
May 16, 2003

Cybernetic Vermin posted:

entirely meaningless clutter carrying the possibility that one of the 30,000 copies of the line is wrong somewhere (one obvious case being that the wrong class is sent and things don't get filtered as expected)

you could do this to avoid the wrong class thing

code:
Logger logger = Logger.getLogger(this.getClass().getName());

  • Locked thread