open-ended question Are int[6] and int[7] the same type in the abstract They are in Java obviously but would

i get you
starting to sound a little bit more like a bank

So I'm taking money from people 'in general', no real restrictions there, and people 'in general' have a claim to money I have under my control. So the law applies. Now we've explained to our national bank that in this case, blogs and the like aren't just gonna go under because we fuck up, atl
east not in the first two years..
and jumping through all those hoops for a licence is jumping the gun - no one has ever done something quite like this before so who knows if it'll work? - and last but not least if needed we can stipulate in our EULA that we can't GUARANTEE to cover anything over 150 bucks, which removes the
whole "I rely on this schmoe's IOU" thing.

no one is gonna go bankrupt by not getting 150 bucks.
I'm confident we'll get either a complete green light or at least a free pass for a year or two.

what's the easiest way to design my code to use a status bar
assuming that my code needs to load some stuff
from disk
do I make the status bar like a singleton?

hello all, I cannot view java applets in webpages; the plugin shows blank and I get this file appearing in my home directory: http://rafb.net/p/EEvn8K70.html "java -version" shows "java version "1.6.0_02" Java(TM) SE Runtime Environment (build
1.6.0_02-b05)"
do I need to switch to java 1.5, or is this more complicated?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea.

~tell warriorness about applets

warriorness, Check the topic, read the Wiki… Essentially we try to avoid them

even those embedded in webpages?

are there really any other kind of applets?

I mean, I don't like applets as much as the next person, but it's not my website that I'm dealing with
so I don't have much choice

sounds more like a question for a windows browser plugin help channel

the point is, we don't support applets here. especially 3rd party applets. you should talk to the vendor if you're having issues with their applets.

I am using linux

check your firefox plugin directory
you'll need a symlink in there

a symlink to what?

to the java plugin .so

/usr/lib/jvm/java-1_5_0-ibm-1.5.0_sr5/jre/bin/libjavaplugin_oji.so

what folder is that in?

what is a folder?

what directory, I mean

depends on your distro

gentoo

jpf-suse:/usr/lib/browser-plugins # pwd
crap
well
gentoo is weird

hm, "slocate libjavaplugin" shows nothing outside of the /opt/sun-jdk-1.6.0.02/jre/ directory

and this is why we don't support them

well there you go
so make a symlink and problem solved

what's the best libraries I could use to build a GUI
with Java
and is it possible to compile a Java project for a specific OS
into a binary

swing
swt

why would you do that?

~tell sleepster about exe

sleepster, I guess the factoid 'compile to exe' might be appropriate:
sleepster, compile to exe is http://www.excelsior-usa.com/articles/java-to-exe.html and http://javafaq.mine.nu/lookup?100
sleepster, compile to exe is a href="http://www.excelsior-usa.com/articles/java-to-exe.html"http://www.excelsior-usa.com/articles/java-to-exe.html/a and a href="http://javafaq.mine.nu/lookup?100"http://javafaq.mine.nu/lookup?100/a

and yes, there are native compilers for java, but why would you kill one of the major plusses for java

and not only one of the major pluses, why kill your performance

meh, it's been way too many years since I've used java, I've forgotten all the simple stuff. Someone remind me where join(stringarray, delimiter) is hiding

StringBuilder

aha, thanks

well how do most people distribute a Java application?

.jar
or java webstart

in a jar
distributing an exe would be stupid

*cougheclipsecough*

surely you're way too smart for that
note that eclipse is a small exe just like java.exe
and I really doubt ol' sleepster here has the resources that IBM did

eclipse is weird anyways

so what's the best GUI package
I could use
I don't want to use swing

and why is that?
same reason you wanted an .exe?

swing or swt. those are the ONLY real standards for java web host gui's, unless you want to bring gwt into the mix

if you want to make a java .exe, use microsoft's visual j++ or j++.net
i don't know who would though

or heck, use c#

are they still making j++? It's J# though

oh
well, j++ or j#.net then

i think they stopped doing j# even

I don't think so

regardless, c# is MS java at this point

you sure? visual studio .net 2003 includes J#.NET

i think they killed it in 2005
i honestly don't care

make a self-extracting exe that extracts the jar and runs it? that would be quite pointless though

death to C#

?

c#'s not that bad…it just has a stupid ide

And restricted to one super shitty OS.

really?
aren't there any linux compilers for it

well yeah, that goes without saying
there's mono, which i've heard is compliant, but MS could break it at a moment's notice

c# only compiles to .net code?

Fuck that… why not just use Java which kicks ass on any platform you want.

always use a singleton if you can

c# compiles to .net bytecode, which can be interpreted/compiled/what-have-you by any framework compliant interpreter/compiler/what-have-you-er

that's not strictly true
the WinForms library is highly win32 dependent

currently the only things that understand .net bytecode are MS's frameworks and mono

C# is ok if you really only want to use windows servers

i knew that, i just didn't know C# only compiled to .net bytecode

but frankly, c# is designed to run on windows

ok

why one would want to do such a thing is beyond me

it's the "can't be fired for buying …" mentality. same thing happened with IBM during the 80's

indeed except that sun is as reputable as microsoft
most of the worlds telephony runs on sun
not that I enjoy solaris

you also have the idiot managers thinking that c# isn't jitted

define jitted

just-in-time compiled

JIT?
ah

just like java is now and pretty much always has been

anyway c# is very similar to java hosting but it only runs on windows
their websupport is great

and their documentation sucks

I would stick with java

heh. i do c# for a living right now. as soon as i get some real experience, i'm finding a java programming job

fanook, why change?
i mean, C# has better generics!

because i dislike the c# programming environment. i needed experience on my resume and Progressive looks good

we're hiring java people in Vancouver and Toronto

what do you do?

Gambling.

vroo

fanook, well that's a good argument

i went from getting my BS straight into grad college. finished last august and did contract work in basically 3-month jobs. started at progressive back in march. good working environment, great name for a resume, wish they had stayed with smalltalk a bit longer

They had this weird idea they wanted to be able to sell their programming ability.

fanook, so you're an M.Sc or Ph.D now?

Smalltalk, for all it rocks, is a hard sell these days.

M.Sc, comp sci, yeah

kewl

i know, but i would have liked to have learned it

heh, never seen a coder with a phd
i wonder what they're like…

they're profs

Knuth, Djikstra

can someone point me in the right direction for playing back to a specific mixer

i plan on teaching someday, but i'd like to actually make some money first

kwhat, java sound api?

need a bit more specific than that

are you using the java sound api? (it's not the only way to do sound in java afaik)

yes i am no jmf though
objOutputDataLine = (SourceDataLine) objMixer.getLine(objPort); where objPort is an instance of Port.Info
that creates a class cast exception
i can get a line but i cant figure out how to write to it.

kwhat, sorry, i've only done very basic .wav playback via the default mixer (AudioSystem.getLine(…))
kwhat, does your code work with the default mixer?
kwhat, if it doesn't, the problem must be elsewhere

yah it works fine on the default mixer… i just cant figure out how to write to a specific port
there is almost no documentation out there on java sound

kwhat, ah ok… well, obviously casting to SourceDataLine isn't working

yah
i can open a line but then its like ok now what, cant write to a line
how is this so hard

have you considered doing a println(getLine(…).getClass())?

so is there a way to compile javascript with javac

suppose i was writing something like a chat server…would using 1 thread per connection scale in java or would i be better off multiplexing synchronous IO (like using select() in C) ?

~javascript

Fanook, javascript is Javascript has nothing to do with Java, just like sweetbreads are neither sweet nor bread. If you need help with Javascript, ask in #web. Ok ?… http://i17.tinypic.com/6euw47k.png

no, javascript is replyJavascript has nothing to do with Java, just like sweetbreads are neither sweet nor bread. If you need help with Javascript, ask in #web. Ok ?… http://i17.tinypic.com/6euw47k.png

Okay, Fanook.

javascript != java, but Google web toolkit is designed to let you sneak javascript into your program

anyone speak german

look at java.nio

but surely javascript must be a superset of java

completely unrelated language.
the naming is unfortunate.

look at Rhino, I believe you can create classfiles with it

i understand that java is compiled

okay, so you're recommending the synchronous multiplexing?

so javascript must be interpreted, no less…

javascript is named that because java was "hot" at the time. the proper name is something along the lines of EMCAScript

class com.sun.media.sound.PortMixer$PortMixerPort

Fanook, ah, so they are both derived from emcascript?

from what i understand of what you're trying to do, yes
hell no. java is NOT A SCRIPTING LANGUAGE

thats what i said

okay that was my 'gut' feeling but i don't use java very often. thanks

but then you said they both are from emcascrpt

but…
java is for webpages

no, read what i wrote again. i said javascript is a flavor of emcascript

its a clientside scripting language
see?

Atalanta, exactly.

look

thats what i said
like in the browser

javascript != java end of story really

d'oh, tis not a fork

right
java \in javascript
i.e. superset

yeh when i use the Internet Program with the E on it, it has java

java is not, has not, and never will be a scripting language. it is a statically typed, compiled language

anyone know wtf PortMixer is ?

no, java \intersect javascript = {}

http://rafb.net/p/rt2nLg63.html

lispy, stop trolling

it's really annoying to people here that you'd insist the are similar

JMenuBar*

operator ?

well why does javascript have java in it if it isnt based on java

Atalanta, you missed the convo
they are both based on emcascript

about what

Fanook explained that actually

they were trying to ride the wave of popularity java had at the time

ah

originally javascript was called something like livescript

well i know what freebasic is

peace-keeper: what does that operator do?

its not really basic, its gcc compliant but it has basic syntax
and it compiles yourcode into asmfirst.

Atalanta, thats nothing like java and javascript
they are both for browsers

peace-keeper: the Comparable interface's compareTo method *kinda* works like that, but it can return numbers beyond -1 and 1 — check the javadocs for it

it has stuff like memberfunctions and properties inside types, which is neat

java especially is based off of emcascript

and it has umm… c/de-tors
*con/de-tors

java isn't for browsers

peace-keeper: is that the quaternary operator? either use Comparator/Comparable for that or a bunch of if statements

it's a general purpose byte-compiled language

applets…. but i agree, java isn't for browsers :P

java is inside it. check this: http://www.qbasic.com/chat.html
thats where a java script is
its made in java

com.sun.media.sound.PortMixer ???? API ???? anyone ever seen this before ?

thats my proof
last time i checked the page though was about 9 years ago so it might not work

lispy, of course it is. sometimes noscript asks me to allow the JAVA program to run in my BROWSER

that's a private sun class, i doubt anyone's looked at it outside of sun

therefore java and javascript are both similar and for the browser
it makes sense really
took you long enough

FUCK YOU SOHAIL YOU TROLL SHIT
lets all put him on /ignore guys and go about our char

Atalanta, calm down

chat
so hows the wife and kids Fanook?
fuck you trollasshole
go to hades

imaginary

Atalanta, your command of the english language is stunning

… /ignore

this is…. entertaining.

what's going on?

i dont know you or who you are. we've never met

hmm…nio looks a bit lower level than i want to work with, perhaps i'll use threads for now but do it through an interface that lets me use nio later if performance problems appear

godling, I am trying to convince Atalanta that java and javascript are the same

yeah i concur AND agree

heh

wtf is Atalanta …
oh right

stupid

no nevermind I want to learn more javascript

hey dimensiOn what you workin on this time
, old pal?

[Atalanta]: delphi
lol

that isnt javascript related though
why arent you in #delphi

eeeewwww, delphi…

i'm
lol

oh. well why you in here?
this isnt a social channel you know
=/

that rather depends on your point of view

well i don't told you i don't use javascript

at least switch it up a bit and equate java to MS' jscript

not vbscript?

wtf is jscript, n00b?

jscript is a dialect of java
they are only superficially different (i.e., in name)

ok i prefer html than mircscripting

I can code html
Im an HTML programmer!
\o/

woot

man wheres the fuckin mods when you need em
your all a bunch of n00bs who dont even know what javascript is
=/
=\

javascript is the shiznit

for someone who is claiming this isn't a social channel, you sure are being very social

it's saturday night. all the mods have real social lives

DO YOU even know what social means?

yes, please stop feeding sohail

i bet you dont and your just in like 6th grade

"you're"
-like

see? you even spelt it wrong
it doesnt have quotes on it when you arent saying what someone said

spelled

spelt?

aren't

spelt is a word
look it up noob
http://wordnet.princeton.edu/perl/webwn?s=spelt

rofl, princeton.

Spelt is a grain.

yeah your in 6th grade yocant scoff at college guys
yeah a noun, but VERB IS NOT
you dont even know the difference LOL YOUR A NEWBBBB
NEWB AT LIFE!

ignorelist++

[Atalanta]: hey, einstein!

Damn, looks like someone needs to go out and make some friends.
Oh, they can't. That's why they're in here on a Saturday night.

see this guy knows im smart, listen to him

yeah

YOUR ONE TO TALK LAMER
man you guys arent even 1334

you guys don't even know javascript/java from python
one is a SNAKE
noobs

WHERES AN OP

javabot ops

cheeser, pr3d4t0r, jottinger, Javageek, jor, Logi, Sou|cutter, {aaron}, kinabalu, flippo, and joed. If you have an issue with channel operations, contact any of the above.

fuckin lamers all up in the hizzle =(

[Atalanta]: can you teach me how to be a l33t h4×0r?

joed, can you help, please!

oh shit Atalanta is hacking me right now

no you hv 2 learn 2 do things UR self

he is sending me ascii porn

haha careful i have norton antivirus

omg
careful I have norton antivirus
OMG
lol
omg
sorry
funny

I KNOW HOW TO BYPASS NORTON MY UNLCE IS THE CEO FOR NORTON
HE SHOWED ME ALL ME ALL THE SECRETS

i have SP2! hahaha loser

man stop it, im serious i have your IP

oh, BIG guy

ok

WHY THE F*CK YOU GUYS BEIN so mean to me anyway

you can use javascript to hack norton

show me

FFS

The one constant in all your unsatisfying social interactions is yourself.

my ip is 127.0.0.1

i will if you dont. i know your IP
YEAH I KNOW I SAW THAT
I KNEW IT BEFORE YOU DID

you can use a fork to eat norton, LOL

[Atalanta]: oh my lord

Atalanta, can you please shut up?

your just jellus cuz you dont even know how to hack like 1334
do yu even know what 1334 stands for?
i do, and thats why im 1334

I can't even tell if this is conscious irony or brain damage. Help.

he's leep?

it meens LEET cuz im leet you *itch

[Atalanta]: yes im |_331

Thank you, kinabalu !

Thanks Kin

ty

He's more irritating than I am!

I'd punt dimensiOn and sohail with that fool.

why?

pragma_, why are you pinging me

the trolling motor starts again

I'm not, you twit.

looks like you're pinging me for some reason

please take this off the channel, nobody cares

ok sorry anything i gotta sleep

Can't we all just get along?

good night all

i haven't scrolled back though
anyway… whatever
pretend I'm American and you're not

:o

What's up?

Never mind, we had someone playing armchair op in here.

pr3d4t0r! you missed the fun

Bummer.
Fanook:
Well, it was kinabalu's day to exercise the muscle.

you would have enjoyed booting this idiot

this guy was acting dumber than I could _EVER_ act.

you hear Dolphin's being discontinued?

Yeah

what's happening now?
:/

Fanook, theyre offering refunds though

Sucks.
Well, since I'm on OS X… I have F-Script

"The nature of Smalltalk with the fact that most of the source is "open" means that existing users should be able to continue using the Dolphin products and not have to port away to other platforms (and hopefully never to C# or Java)."

er i just associated dolphin with java 7…

hehe, i thought someone might do that
although, i had forgotten that codename until about 5 mins ago

Hi, is anyone able to help out with a swing prob?

~anyone

Instead of asking whether anyone works with something you need help with, please save time by asking your actual question. If someone knows and wants/has time to help, perhaps he/she will.

specifically JMenuBar
ahh., sorry

Staz I looked at that and got it to work

really?

Staz not sure what the problem was exactly

hmm, I'll try pasting the whol thing, (not just the constructor)

Staz well all you need is the piece you posted.

really weird it doesn't work then

Anyway. Time to take da girl out; backups just kicked in so my desktop is super-slow anyway. See ya.

i have a javascript question

javabot tell sohail about javascript

sohail, Javascript has nothing to do with Java, just like sweetbreads are neither sweet nor bread. If you need help with Javascript, ask in #web. Ok ?… http://i17.tinypic.com/6euw47k.png

what, is he back?

sohail, stop that. It's like watching you shoot fish.

pr3d4t0r, Giggity giggity goo

ojacobson, lol for sure

javabot no, javascript is replyjavascript has nothing to do with java — see #javascript

Okay, r0bby.

"no, javascript is replyHave you tried #decorating?"

javabot no, javascript is replyjavascript has nothing to do with java — see ##javascript

Okay, r0bby.

Hi, r0bby. How are you this evening?

okay — i'm going to lurk — see ya.

~javascript

javascript has nothing to do with java — see ##javascript

anyone use GWT in here?

javabot tell gaillard_ about anyone

gaillard_, Instead of asking whether anyone works with something you need help with, please save time by asking your actual question. If someone knows and wants/has time to help, perhaps he/she will.

i can't get anyone in #gwt but i am only wondering how to halt the program if a setup fails

System.exit(-1)?

or even where to do a setup, since within onModuleLoad, is after the server gets a request
Fanook, ah ok, but do you know where in a gwt program?

no idea. i use swing

Fanook, darn, ok thanks though

I'm a GWT user.
'halt the program'?
It's a website.

Have a nice evening.

wake up

oh hey
sorry

no problem.

Going out with das Girlfreun fur some Gooddinneren und Drinkeren und Sexoren.

rewind.
What are you trying to accomplish exactly, gaillard_?

surial, i just want to run a server service on startup

on startup of what?

surial, that will do some dbase magic to make sure everything is good before anyone trys to access a module

On startup you want to make an AJAX call to the server, and there are two 'trees' of results here: 1 - the call succeeded and we want to change stuff on the page, or 2 - the call failed and we want to change stuff on the page. other stuff, but still.

tazle, server startup

is that about right?

that has nothing to do with GWT, then

tazle, where would you code it then?

stop listening to tazle for a moment and answer my question.

ok, you handle this

or actually, apologies, tazle. On review I think you've understood him better than I did.

surial, i just want to have the server check some server stuff on startup

sleep

haha

on a per-user basis, or when your server ITSELF boots?

itself

okay. wow. you really need to untangle the mess in your brain.
That is compltely not related to GWT.
Your GWT code runs on the CLIENT.
you do get that very basic fact of GWT right?

yes but it can make server calls, i figured it might have to be done that way but i guess not =D

…. think about it for a moment. About how stupid that would be.
Unfortunately, doing any sort of maintainance work is non-standard in a servlet environment.
In other words, it depends on your server. apache? tomcat? tomcat via apache? jetty?
however there's a workaround - ALL your servlets should, as first act, call SomeClass.initialize().
which does the setup shit. and that method returns a boolean (true/false), which is false tells your servlet: Hold your horse, shit is broken, abort. At which point the servlet will for example send this back to GWT so that GWT can show to the user: Uh, I fucked up - come back later.

but gwt uses some embedded tomcat thing i think

sigh
GWT uses NOTHING. it is client side technology.
GWT has a 'hosted mode browser' which is for TESTING ONLY, and it has a built in tomcat to make your life easier.
But what's your plan - to use the builtin tomcat of hosted mode to serve your customers?

that is what i am using at the moment for testing, but i guess i will have to add this setup stuff only for the non hosted mode?

that initialize() thing I just explained works everywhere. hosted mode, non-hosted mode…

do you know where it is called from in the embedded tomcat hosted thingamawaby?

that didn't make any sense
define 'it'
and define 'thingamawaby'

initialize()

YOU CALL it!

from?

doGet/doPost/doGWT-RPCThingie, in EVERY SERVLET.
and of course that initialize() thing has a protector so that it only runs once. after the first run it returns whatever it returned the first time.

i am looking for some classes in the tomcat folder but not finding any

boy, you're dense. Listen to what I'm saying, forget tomcat, GWT, just think 'plain vanilla java'.

surial, my wife likes her java with French Vanilla. ;-)

every single time a servlet gets called to handle a request, you FIRST check with a central point if everything's in order. YOU WRITE this SomeClass.initialize() method. This method first checks if it has already run. If so it returns the cached result of that first run. If not, it runs, then
stored the result in the cache, then returns.

ok but i have no idea how they set up this embedded server for the standard gwt download

You've got some fundamental misconceptions about GWT, I think.
GWT is *PURE* *CLIENT* *SIDE*.
the embedded tomcat is a mere convenience, and if it's making you this confused, you should consider it doesn't exist and use -noserver instead.

perhaps i will then, thanks, time to look up -noserver

I've said all you need to know. save this log and refer to it. Go drink some coffee or something, I'm done talking about this.

how do I make Java output data to the console? When I print anything other than ascii, all that comes out is ????? ????
my terminal supports unicode&
is there something I can set to make Java default to UTF-8 instead of MacRoman?

!binascii 01000110 01101001 01100111 00101110 00100000 00110001
oops wrong channel
sorry

is it not possible to read from the console when you start the process from eclipse?
(new BufferedReader(new InputStreamReader(System.in))).readLine()
hmm…no that does seem to work

you should check the javascript reference

shhh.
he's asking about java.

s'okay i have sohail on ignore
so, i'm tweaking some example java.nio code i found and i suspect the example has a bug
http://rox-xmlrpc.sourceforge.net/niotut/index.html
sometimes the NioClient just freaks out instead of initiating a connection
it seems that sometimes the NioClient calls write before anything is sent

Reading the prose, it looks a lot like he's making assumptions about thread timing

hmmm…where at?
well, at this point the server seems to be working fine (tested it with telnet)
it's just the client i'm still fiddling with

He sets interest in writing as soon as the connection is complete, regardless of whether there's anything to write
I didn't read the source closely enough to see how his threading works out

okay, that seems to be the spot i had to fix
so we're probably on the same page about that
i fixed it by checking if the write queue was null, if so i just don't try writing
and that way if write is called before things are initalized, no big deal

it could still be buggy, depending on whether you switch back to OP_READ when the queue is null, or not…

JMS *fist-shake*

yeah it seems like the default state for the client should be read
and if it happens to be sending, switch to write
then back to read

or even add write
(You can do both in one pass, that way)
Should only read if there's something ready to accept the read data, probably

he goes on about how you get yourself into complex situations if you try to allow read/write at the same time

Mm. Depends on how the rest of it works.
Since it looks like it's "write request, read response, disconnect", defaulting to "do nothing" until there's data to write might be sane

i'm extending it to send data and accept data without disconnecting
and to make the server side echo to all connected clients
the server side is done
just having some weirdness on the client still

hi, can anyone help me in streams please?
well, my problem is I cannot undrestand what does stream and Buffer mean.
Can anyone hear me?
hi Jonny, what does Buffer mean?

here's an example
you're writing to a file
you can either write each byte to the file as you get them
or you can save up x many bits and then write them all to a file when they reach some limit
the buffer is where you store the bits if you go with the second route
which you would do due to i/o constraints

well, ManUnderground, where is Buffer physically?
I mean does it have any device like RAM ro sth else?

its in memory
it's just some piece of memory

does Buffering increase the perfomance?

ya
writing to memory is very expensive
sorry, writing to a file or a hard disk

actually my problem is in working with I/O streams.
I cannot undrestand the differencees among all classes derived from Reader.

ya, there are a lot
what are you trying to do?

well, in Herbert Shilt's book he has tried a method, using this:
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

Morning

int j=br.read();
but I can do the same with less code:
InputStreamReader isr=new InputStreamReader(System.in);
int j=isr.read();
as you see they do the same, but what is the difference?

~BufferedReader

deebo, I have no idea what BufferedReader is.

~javadoc BufferedReader

I don't know of any documentation for BufferedReader

start here
http://java.sun.com/j2se/1.5.0/docs/api/
and search for the buffered reader
which might help

if you want to get some charachter from console, How do u do it?

"In general, each read request made of a Reader causes a corresponding read request to be made of the underlying character or byte stream. It is therefore advisable to wrap a BufferedReader around any Reader"

why is it advisable?
i mean why don't do that with another class?
like BufferedInputStream

"Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient."

well, I cannot really undrestand how does the bytes written from console can be Buffered

at this point I wouldn't sweat it, and I'd just keep going with whatever works

sure, you could use BufferedInputStream to achieve the same goal here

Great Idea!
what is the difference? is it only the buffering?

difference between what?

between BufferedReader and InputStreamReader

there's also a difference in how you create them - InputStreamReaders are created with an InputStream, BufferedReaders are created from another Reader

yeah, The hotspot is here
does BufferedReader make InputStreamReader to get Buffered?

you can wrap an InputStreamReader with a BufferedReader to add buffering, yes

can we use BufferedInputStream(…) instead of BufferedReader(new InputStreamReader(…))?
I mean does that exactly do the same?

BufferedInputStream is a byte-level buffer. BufferedReader is a character-level buffer. It's possible that one character will be more than one byte — UTF-8, for instance, will use up to 4 if it has to.
That's the only difference.

new InputstreamReader(new BufferedInputStream(is)) is a lot like new BufferedReader(new InputStreamReader(is)), yes.
they both provide a Reader API that uses buffering of some sort

well, thanks all.
let me ask another question please

heh, oh alright

I cannot undrestand the meaning of API, I know it is Application Programming Interface, but I cannot get the consept

think of it as a language built on top of java
a higher level language

can u give me an example please?

so when you're writing an application you're writing in that language, which is defined by its API
or you could think of it as just being a set of tools
to do common tasks

The class java.lang.String (a concrete thing) provides an API for manipulating strings (an abstract concept) in Java programs (a concrete thing)

an "API" is the interface the programmer sees. i.e. the java.io.Reader API is close(), read(), reset() etc…

interface myInterface … ?

how would I determine which segment of code gets executed the most
in my application

profiler

is there a good one
that can be installed quickly
with eclipse

I mean if i create some interfaces, have i created an API?

in java an "interface" means something specific - basically a name and a bunch of abstract methods classes must implement in order to declare that they support that interface

that's the first tep
but generally an API is something that you expose to the public

"API" can refer to a whole bunch of classes/interfaces though, e.g. "the logging API"

Anyone ever use YouKit profiler

it's a contract between the code's owner and the code's users

the code's oeners create the interfaces and abstract methods,

I use Yourkit at work
It's pretty solid

so they have created API, am i right?

right
and once the API is published, such that other people are using it
they can't change the interface
because that's the deal
so that's why Java has depreciated methods

Thanks, now I got it, Wonderful!!!

(Sun, may their collective armpits develop scabies, is really big on producing APIs and demanding the whole world conform to them. _ )

thanks all, bye

ya but is it surprising? an API is a platform, and every business wants to have their own platform
take it easy

JMS.

'cept they like to call 'em "standards" =P

I don't have an issue with them producing an API + implementation
I do have something of an issue with them producing an API and implementation, declaring the API standard, and letting everyone else play catchup.
which reminds me, how the fuck do I tell the EJB timer service in jboss to use a real database without giving it permission to configure the DB itself?

can't help you there

what would be more intensive… do something like: If (Something == null) { … } or try { Something(); } catch (NullPointerException) { }

always do the former
exceptions are much more expensive
and frankly you shouldn't be running into exceptions of that sort

Catching NPE specifically is a sign you don't know how to handle nulls yet.

as a rule you shouldn't really use exceptions for flow control

thanks

Except when it would be fun to do so.

but try is fast, catch is slow.

Nonsense.
Both are pretty damn fast. It's building the exceptions which is slow.

hmm.. how about throwing like IllegalArgumentExceptions
instead of just returning false

good

that's good

i think you just disagree with my terminology =P

any suggestions for a good profiler?

Not really. My point is that both try and catch are fast, it's throwing the exceptions in the first place that slows things down. This is an important distinction, because it shows you how to speed up the process.
YourKit is highly recommended, but nonfree. Netbeans's profiler is good for memory but bad for time profiling (although I don't know how it compares with others for time profiling. Time profiling seems to be a black art).
~tell sleepster about profiler

sleepster, A profiler is a tool to find performance bottlenecks. jmp and ejp are free; jprofiler and jprobe cost money. Some more are listed here: http://javafaq.mine.nu/lookup?169

Yourkit has served me well

Yourkit is free isn't it?
I am downloading it

Didn't think so.

hmm..

It has a trial version.

It's trialable, I believe

oh I see
that stinks

so, code issues aside, which one will be more efficient in the long run depends on how often you expect the exception to be thrown

hmm I see..
oh is this the IllegalArgumentException
that we are talking about?

no, the original NullPinterException question

oh I see
well I think it would be weird to check for run time exceptions

frequently, but not always. Counterpoint: NumberFormatException.

hmm.. yeah I see

CREATE USER SA PASSWORD "" — thanks, jboss CMP!

if i have a java.net.Socket and call close() does it disconnect the socket?
Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created.
so you would think it would disconnect?

It (1) sends a FIN packet to the remote host, terminating the connection (for TCP/IP sockets) and (2) tells the OS to close the socket and release its resources.
Consequent to (2), any further packets arriving for the socket will be returned with a RST packet, I believe, but you'd have to check the TCP spec.

well i might be looking at this incorrectly, i think i might have misinterpreted what this method is doing

How so?

" + socket.isConnected() then i called socket.close() and printed out "Connected: " + socket.isConnected() again and it displays true on both
but reading this javadoc it says
true if the socket successfuly connected to a server

isConnected will return true forever after connect() is called or the connecting version of the constructor is ues.
isConnected is *not* *not* *not* reliable for telling if the socket is still connected; the ONLY way to do that (on any OS) is to try to read or write on the socket.
It should be "hasConnected", really.

but why is that, just looking at the method name you would think it would tell you if the socket is connected or not

Presumably, bean naming convention overrode common sense
isFoo is the normal
er, normal convention for read methods for boolean properties

well let me see
if i create a new socket, doesnt it give an IOException if it doesnt connect?

Not if you use new Socket() rather than new Socket(address, port)
The former does not connect to anything; you have to call connect(…) yourself

so if i use new Socket() i have to call connect(…) myself
but if i call Socket(addr, port) it connects

right.

yes, the api explains all that as well

but i am trying to understand this
connect(…) throws an IOException if an error occurs during the connection

The Socket(addr, port) constructor calls connect for you; this is why that constructor also throws IOException.

so let me ask this, if a socket closes unexpectedly will isClosed() return false?

Not until you call close.

so how do i know if a socket is still connected?

By trying to use it.

thats the only way?

It's a fundamental truth about TCP/IP that the only way to tell if a connection is still viable is to use it
Until you send something, you have no way to check if, say, half the internet has quietly disappeared and your peer has become unreachable.

true, why ping/pong is in IRC

I've never found a good use for isConnected or isClosed… I never have to check the state of a socket because I know what state it's in at various points in the program.

alright well thanks, i understand it now
kinda sucks that they used that name though, lol

Truth
(Nice part is, if you don't care about latency, if a peer is temporarily unreachable but not for long enough for "no route to host" to be provoked then the connection will recover when the network recovers.)
(TCP doesn't say *when* a message will get there, only that it will get there, and that it'll be in order.)

oh, while i am here
i created a BuffereReader on this socket and when i call BufferedReader.readLine() it takes 20 seconds to read the line but if i try reading it byte by byte, it is instant
sorry if i dont make since, i aint the best at explaining things
someone said something about them having a simler issue and that it was the client was trying to read to much or something and it was waiting for it to finish
i forget exactly what he said
i no longer have the code, but basically i created the BufferedReader off the socket and threw it readLine() in a while loop

readLine will continue to loop and read the underlying reader until it encounters an end-of-line sequence
Reading a fixed-size buffer (or one byte) yourself will fill as much of that buffer as possible in one read and return immediately.
(Blocking if no data is available to read yet but the connection is still open)

so this is no way of fixing it besides just reading a fixed size buffer
so there*

That's usually how I approach it. Or to use NIO, which pretty much forces you to do your own buffering.

hrm, alright
thanks for the time and help

No problem.

well, you need to decide whether you want to block and wait for a whole line or not

^ that
if you really need a whole line, you'll spend just as long reading in your own code as bufferedreader would

so i can have the buffer wait for a line to be read?

if you don't, reading a whole line is a waste anyways

that's what readLine is doing

Hey, in swing what is the usual way of accessing a JMenuItem and setting one of its values?
Should I make the menu item global?

BTW, this code i'm following is really brain damaged. It allows for race conditions were you wanted to do a read (or a write or finish a socket connection) but that gets over written by later requests

What is the best way to go about it?

when you say reading it byte by byte reads _a line_ instantly but readLine takes 20sec, it sounds like there isn't really a whole line there

I knew I smelled something.

hehe

For what it's worth, asynch IO is a fairly hard concept if you've never written an event-driven system before

when i read it byte by byte it takes about 100 loops to get the entire line

You basically end up discovering all the painful things the authors of Swing discovered
("multithreading is hard" being one of them)

http://java.twistedmatrix.com/eio/ source might have some good examples
or you might even choose to use it instead of NIO directly

if not, apache mina is reasonably good

thanks
oh, zooko
i know him

I throw BufferedReader.read() into a loop

Aha.
The first read is reading as much as possible into the bufferedreader's internal buffer

http://java.twistedmatrix.com/eio/docs/

SUbsequent reads, until that's empty, are coming off of that
not the socket

yeah, i noticed that too

hi… is it possible to serialize a Blob from
?

ojacobson?

ohayo?

not sure i understand

The way buffered reader works is, every call to read checks if the internal buffer is empty
if so, it fills it (one read to the underlying reader), then returns values out of it

i think one way to salvage this code would be to have seperate queues for the different actions
and then empty them out as they fill up

fire is also a good solution
as in "burn it with"

heh

why? why can't database schemas be nested? bah

i just want a simplish but performant way to implement a chat server…with the eventual goal of creating a game server around it

you don't even want to know how I'm approaching that same problem

no i really do

no, you really don't. jboss is involved.

ahh

is there any way that i can check to see if there is stuff to be read before I call readLine() so it doesnt take 20 seconds

I still have to write all the networking crap myself, but it's saving me from having to write the rest of the infrastructure for getting chat messages from point A to point B

fwiw, i tried this same problem about 2 years ago in haskell and i couldn't get the abstractions working to my taste there either

(fortunately, in a past life I did network code for a living)
(in C, so NIO is a bit of a culture shock, but still)

what are you going to do if there isn't stuff to be read?

wait until there is stuff to be read?

that's what bufferedreader is doing.

so why not just let readLine wait for you?

if you do it, it'll take just as long.

i'm tempted to do a select (or poll) implementation in C but i don't trust myself to get the code correct if i'm using C

What you might try, just for grins, is writing a LineReader that just implements readLine the simplest way you can think of

if i call readLine() it takes 20 seconds to read a line, but if i call read() it pulls out the first charecter instantly - i must not be understanding

it's not hard, just tedious as all gtfo
it's not the first character that's the problem — there may not be *all* the characters yet, and readLine won't return until it's gotten an entire line

so you are saying that the server isnt sending a new line?

or that it's getting delayed

i'm used to languages (like haskell) where you can use the type system to prove you haven't made bugs of certains types…so to me C is like running around naked

and thats why its taking so long?

or the *wrong* newline…

ew, put some damn pants on

so i kinda avoid that…

twistedmatrix.com is how you might do it, in python ;-)

well readLine waits for a line feed or carriage return

or it's stupid about how it handles \r\n. common problem

anyways, I try not to abuse the representation/type equivalence in C, evne though it's tempting
it makes the code much more verbose, but it also makes it much more robust

right

readLine() is stupid about how it uses \r\n?

it used to be, iirc. not sure about now.

well, i'ma sleep on this code/problem and maybe i'll fix it soon
nighto

nihto

well when i call read() will it read line feeds and carriage returns?

it *should* return on \r *or* \n, and ignore a leading \n if the last line ended with \r.
it will read characters. any characters.
read() doesn't care about lines.

Your best bet is probably "don't use readLine on sockets"

the other end may be using a line buffer, though

hrm, so how the heck am i going to know when the line was suppose to end if i use read()

wtf. Is it just me or is the reasoning for the generic return type of getConstructors() the lamest excuse ever?

reading…

you parse the buffer yourself, looking for line terminators

Oh well.
The amount of unchecked cast warnings my code generates is a bit embarassing.

what reasoning?

I'm sure it will bite me eventually.

I don't see any reasoning in the Class.getConstructors javadoc

Why it returns a Constructor[] instead of a ConstructorT[]

should i just write my own readLine() _

http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getConstructors()

oh right, java *six*

what protocol are you implementing?

cant say, dont wanna say now cause i just thought about something
lol

Java 5 doesn't have that note

Yeah, I know. But getConstructors() returns a Constructor[].

haha, Sun discovers that java doesn't have const types. News at 11.
That's awesome.

alright well, i think i got enough help here to get me going again

This is why arrays don't belong in high-level languages

thanks for the help everyone that helped, especially ojacobson

Cheers, mate. Good luck.

Not really. It's why the covariant behaviour of arrays is Wrong.

That too.

whoah, just realised my birthday is in 2 days

Arrays are kind of a weird hole in the type system.
(Java has many.)
The fact that T[] can be assigned to Object[] is, IMO, a mistake that was necessary when generics didn't exist.

Yeah
I really wish oldstyle arrays would be deprecated and replaced with a properly generified version, but it will never ever happen.

just create your own language that has it…

There's no reason to create m own language that has it. I can create my own class which has it. I never use raw arrays except when interfacing with old code which does.
And Scala already does it, so even if there were a reason to create my own language for it, someone's already beaten me to it.

I usually try to stay away from arrays nowdays as well…

In conclusion, your comment has no merit. Have a cookie.

Primitive arrays are sometimes useful.
Reference arrays.. less so.

That's true. In order for my proposal to work, generics would have to be updated to work with primitives.
But… they should be anyway.
WEll, I guess that's not true.
You'd just have to have different classes. IntArray, CharArray, etc.

0AM and i dont feel like getting tired while writing this packet reader so i might as well go to bed while i am at a good stopping
so g`night all

o/
open-ended question. Are int[6] and int[7] the same type, in the abstract? They are in Java, obviously, but would you treat them as being one type, or one generic type (int[]) with two concrete types?

i just thought about something

?

I would *like* to treat them as two separate types. However in the absence of a dependently typed programming language I'm satisfied to use I'll stick with treating them as one type.

if i am reading from the BufferedReader constantly, i should be able to tell if the socket is connected or not instantly so i could probally just write my own isConnected method and have a boolean that represents if its connected or not

I'd rather have them a single type than a template for example.

you could indeed do that, but it'd still be (somewhat) wrong
in that by the time you get a chance to look at the boolean, the connection could have gone sour
If you treat it as "was the last read successful", then it works
beyond that though

the read() should throw an IOException if it has been disconnected, shoudlnt it?

yes.
If it disconnected cleanly you'll get the rest of the input, then a 0-length read, first.
If the connection was lost, the remaining data will be readable; the first read that goes off the end of that will throw an exception
(no 0-length read first)

well if it was a clean disconnect i should know without reading the buffer
or if the server ends the stream
then i guess i wouldnt know

Right

unless i used read
alright, thanks again

You'll only know when you read and get a 0-length read.
(Network programming involves a certain amount of "just assume the other side is doing the right thing")

what if a packet was changed by some hacker inbetween

You can't protect against that in code; trying will simply confuse your code

use SSL

If you're using SSL, the connection will break at that point

this reading and parsing might be a little more difficult then anticipated
its an XML based protocol

oof
XMPP?

how did you know?
lol

They're the only maniacs insane enough to use XML as a wire protocol for a standing connection

its kinda cool if you ask me

Eh. It has its upsides and its downsides.

i just dont think reading and parsing is going to be much fun

You might be able to elide this whole issue and use JAXB to do the parsing.
I saw something while I was reading the docs.

i just planned on using read() until it has nothing to read, then check if its a valid node or nodes and parse them

You still have to parse the root element yourself, but the messages themselves are self-contained enough
Turn that around
Read, append what you read into a buffer that you're building up (stringbuffer is fine), then check if you've got a whole node
if so, parse it and remove it from the buffer (leaving anything after the node that was already recieved)

i planned on using a StringBuffer and checking if there is a valid node or not when read() doesnt read anything
does read() loop?

read() generally doesn't
Since Reader and InputStream are interfaces, I'm sure there are at least one implementation of each that does

loop in what sense? I'm sure e.g. BufferedReader has loops in its implementation of read.

i mean if i did something like

Oh, right. loop around to the start again? That would be bizarre…

int read; while((read = reader.read()) != null) { System.out.println("Read: " + (char)read); }
"
printing*
so is read() waiting for something to be read?
before it returns

null is the wrong thing to be checking against.

alright but still
i should be checking -1
right?

Yeah.
It will probably block.
(If there's no data available I mean)

" isnt going to be printing out a billion times

If there's no data, the connection has not yet reached the end of stream, and no error has occurred, it will block.
Unless you explicitly set the socket to non-blocking mode, in which case it will spin and consume unholy amounts of CPU time.

Shouldn't do, unless you read a billion characters.

well, waht i ment is read() doesnt return until there is something to be returned

*nod*

correct?
did you *nod* yes or *nod* no
lol

nod yes, sorry. In general read will not return until there's something to return or something goes wrong.

Where 'goes wrong' means 'the person who implemented this reader fucked up'
(Or, I suppose, the stream terminated prematurely)

I was thinking "unexpected RST"

alright, so i am going to still have to check for an end of line
cause i dont wanna check the stringbuffer for a valid node each byte written
read*

Ideally you should use one of the other read() forms which read larger buffers at once
they also only read once, but they may read many characters at once
if you don't have a bufferedreader or some other buffering mechanism in the loop they usually also only read as much as is immediately available, ratehr than the whole buffer

do i have to specifify how much will there should be exactly?
lol wow, my grammer _

you have to specify an upper bound for how much to read at once (in the form of buffer size)

so if i said read 100 bytes, will it wait tell it has read 100 bytes?

oh
not usually. BufferedReader may or may not. Reading straight from the socket won't, unless it has to block and 100 bytes arrive before it unblocks.
If there are 25 bytes available already, and you try to read 100, you'll get 25.

actually, wait

Relatively immediately.

wait wait wait, i think i know something that is going to help
give me a second
there it is
http://java.sun.com/javase/6/docs/api/java/io/InputStream.html
would using InputStream, the default stream for a socket be better?
cause it has available()

available() tells lies too.

but its going to be easier then saying read 100 bytes

It's really only reliable for bufferedreader/bufferedinputstream

well should i use InputStream any way?

I'd keep doing what you're doing.

no point in creating a BufferedReader if i am just going to be reading it byte by byte

Read, say, 512 characters at a time.

correct?

APpend however many characters you read (may be less than 512) to your real buffer where you're building messages.
Check and parse.
Repeat.

just calling getInputStream() is going to be easier then new BufferedReader(new InputStreamReader(socket.getInputStream()));

Sure, but then you need to do your own character decoding.
(XMPP is XML, XML could well be encoded in something non-ascii)

just set UTF-8
alright well, i am going to go to bed
thanks for the help again

o/
I'm going to pass out now.
Don't drink the water.

Hm
This is puzzling
The performance of Idea on my home machine is shocking.
Good lord. It's throwing PermGen space errors… The hell is causing that?

~jdk1.5

stickto, I have no idea what jdk1.5 is.

~jdk5

stickto, I have no idea what jdk5 is.

~j2ee

stickto, j2ee tutorial is http://java.sun.com/javaee/5/docs/tutorial/doc/

~iptables

stickto, I have no idea what iptables is.

DRMacIver, are you using idea + tomcat?

Nope.

Just Idea?

Just Idea, working on a relatively small library project.

hm, strange.

Might just be that it's a 64-bit system so things tend to take up more memory and the default settings weren't enough to get good performance (so it was eating into swap or something).
(for the performance issues. Obviously swap has nothing to do with the PermGenSpace error)

test

morning

evening

'lo jottinger

how goes, eh

p;p;;;;;;l-[,]

morning, cheeser's cat

 Web Hosting | Hosting

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Comments are closed.


Blog Tags:

Similar posts: