 |
 |
Index ‹ java-programmer
|
- Previous
- 1
- Memory Leakage drawing Images from Stream - Minimum exampleOk folks
I posted this a number of times ago,but never posted a minimum code
example for people to look at.
I was trying to load and draw images from a Mjpeg-Stream, reading from
the stream in a different thread.
This is the thread where the images are read by:
public class Axis2420
{
private HttpURLConnection hurlconnection = null;
private DataInputStream datainstream = null;
private String serialNumber = null;
private boolean connected = false;
private Frame dummy = null;
private Image image = null;
private String MJpegStreamUrl = null;
Runnable decodingThread = null;
public void SetURL(String url)
{
MJpegStreamUrl = url;
}
public boolean Connect()
{
if(MJpegStreamUrl == null)
{
System.out.println("Error: Empty Camera URL String");
return false;
}
try
{
URL streamurl = new URL(MJpegStreamUrl);
hurlconnection = (HttpURLConnection)streamurl.openConnection();
hurlconnection.setReadTimeout(10000);
//hurlconnection.setUseCaches(false);
InputStream instream = hurlconnection.getInputStream();
connected = true;
BufferedInputStream bis = new BufferedInputStream(instream);
datainstream = new DataInputStream(bis);
} catch(IOException e)
{
System.out.println("Fehler");
try
{
hurlconnection.disconnect();
Thread.sleep(60);
}
catch(InterruptedException ie)
{
hurlconnection.disconnect();
Connect();
}
catch(Exception ex)
{return false; }
System.out.println(e.getMessage());
return false;
}
return true;
}
//run method of the reading thread
public void run()
{
//test if still connected
if(!connected)
return;
try
{
//decode stream
if(connected)
{
Image i = null;
//ImageIO.setUseCache(false);
long before,after;
while(!Thread.currentThread().isInterrupted())
{
i = null;
String header;
int k = 0;
do
{
header = datainstream.readLine();
//System.out.println("Zeile: " +header);
}
while(++k < 3);
int j = (new Integer(header.substring("Content-Length:
".length()))).intValue();
datainstream.readByte();
datainstream.readByte();
// datainstream.readLine();
imageJPG = new byte[j];
datainstream.readFully(imageJPG, 0, j);
byte tail[] = new byte[4];
datainstream.readFully(tail,0,4);
i =
Toolkit.getDefaultToolkit().createImage(imageJPG,0,imageJPG.length);
image = i;
i = null;
fireChange(); //calls the stateChanged() method in
the class 'MainProgram' below
image = null;
i = null;
Thread.currentThread().sleep(10);
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
try {
datainstream.close();
} catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//for the listening objects so they can fetch the latest image
public Image getLatestImage()
{
return image;
}
<....>
}
Once a new image has arrived, the fireChange() method calls this method
on the MainProgram class:
class MainProgram
extends JFrame
implements Runnable,ChangeListener
{
public static String WINDOW_TITLE = "BINO GESTENERKENNUNG";
public static int WINDOW_WIDTH = 640;
public static int WINDOW_HEIGHT = 480;
public static final int CAMERA_LEFT = 0;
public static final int CAMERA_RIGHT = 1;
//public static final String leftCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=704x576&compression=25&clock=0&date=1&fps=10";
//public static final String rightCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=704x576&compression=25&clock=0&date=1&fps=10";
public static final String leftCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=352x288&compression=70&date=1&fps=5";
public static final String rightCameraURL =
"http://192.168.1.51/axis-cgi/mjpg/video.cgi?resolution=352x288&compression=100&date=1&fps=5";
Image currentLeftImage;
Image currentRightImage;
Graphics leftImageGraphics;
Graphics rightImageGraphics;
Graphics leftCameraGraphics;
Graphics rightCameraGraphics;
byte[] currentLeftImageJPG;
byte[] currentRightImageJPG;
BufferedImage testImage;
Axis2420 leftCamera = null;
Axis2420 rightCamera = null;
CameraCanvas leftCameraCanvas = null;
CameraCanvas rightCameraCanvas = null;
Runnable drawThread = null;
boolean readyToDraw = false;
boolean newImage = false;
long frameRateLeft = 0,frameRateRight = 0;
long frameTimesLeft[],frameTimesRight[];
//vPointerDetector leftImagePointer;
//vPointerDetector rightImagePointer;
vPointerDetector imagePointer;
boolean updateLeftImage,updateRightImage;
<.....lots of meaningless stuff.......>
public void stateChanged(ChangeEvent e)
{
currentRightImage = rightCamera.getLatestImage();
rightCameraCanvas.SetUpdate(true); //otherwise paintComponent()
of the JCanvas won't draw the image
rightCameraCanvas.SetImage(currentRightImage);
rightCameraCanvas.repaint();
currentRightImage = null;
currentRightImageJPG = null;
}
}
}
} //end of MainProgram class
Basically, all the stateChange method does is getting the image from the
image-reading thread ('rightCamera' of type Axis2420) after
rightCamera called fireChange(). The image is passed to an object of the
class CameraCanvas which derieves from JCanvas. After that, we cast
repaint() on the CameraCanvas (rightCameraCanvas.repaint() ).
This is the CameraCanvas that is responsible for drawing:
public class CameraCanvas extends JPanel
{
private Image image = null;
boolean drawNext = false;
boolean readyForNext;
public void paintComponent(Graphics g)
{
if(drawNext == true)
{
readyForNext =
g.drawImage(image,0,0,getSize().width,getSize().height,this);
//image.flush();
image = null;
//g.dispose();
//imageBuffered.flush();
drawNext = false;
}
}
//indicates that there is a new image
public void SetUpdate(boolean up)
{
drawNext = up;
}
//passes a new image to the Canvas
public void SetImage(Image i)
{
image = i;
}
}
The program draws the stream correctly and is smooth like butter.
However, there is a HUGE memory leak somewhere that raises the memory
usage by about 40MBytes per second. If I remove the call to
readyForNext = g.drawImage(image,0,0,getSize().width,getSize().height,this);
in the CameraCanvas thread, the leak will go down to about 40 kbyte /
second. If I leave it in and post a System.gc() call afterwards, the
leak will also go down.
I think that I'm somewhat polling the AWTEvent thread which lots of
copies of images waiting to be drawn. Also using
Toolkit.getDefaultToolkit().createImage(imageJPG,0,imageJPG.length);
spawns abouth 4 ImageFetcher threads which I think are the reason for
the small memory leak.
Now the question: What can I do about it?
It seems that the garbage collection isn't called after drawing an image
and casting it manually via System.gc() slows everything down a lot.
Using ImageIO.read)() instead of the Toolkit seems to remove the small
leak, but not the big one for drawing. And it tends to be slower since
it's blocking and keeping the Axis2420 thread from reading from the stream.
My thesis is due soon, so pleease have a look at it again.!!
Thanks in advance!!!
- 1
- servlet and threadi am connecting to a servlet. i am passing some values from JSP to
servlet. the servlet gets those values from JSP by
request.getParameter(). then the servlet creates Threads as much as
values gives to it.
if the servlet is given 3 values from the JSP, then it would create 3
threads to calculate.
if the servlet is given 10 values from the JSP, then it would create 10
threads to calculate.
each Thread would return results to the JSP.
PROBLEM :
=========
how does my JSP would get the results from the threads. JSP would
refresh in 5 secs interval and would display the latest threads result.
- 2
- java.lang.NullPointerException at com.sun.kvem.midp.MIDP.run(MIDP.java:651)Hi Friends,
Does any one has any idea about the following StackTrace. I am using
CLDC1.1 and MIDP2.0 with Sun Java Studio Mobility. Any help will be
highly appreciated.
java.lang.NullPointerException
at com.sun.kvem.midp.MIDP.run(MIDP.java:651)
at
com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(EmulatorInvoker.java:116)
at
com.sun.kvem.environment.EmulatorInvoker.runEmulatorSameVM(EmulatorInvoker.java:105)
at
com.sun.kvem.environment.EmulatorInvoker.runEmulator(EmulatorInvoker.java:63)
at com.sun.kvem.environment.ProfileEnvironment$KVMThread.runEmulator
(ProfileEnvironment.java:240)
at
com.sun.kvem.environment.ProfileEnvironment$KVMThread.run(ProfileEnvironment.java:262)
Greetings,
- 4
- [eclipse] export with referenced librariesHello,
I am trying to export a project in jar format so that I can run it on
different machines. . I got a NoClassDefFoundError exception because
it requires referenced libraries (in this case, it is the MINA). Would
anyone please tell me how to export with referenced libraries?
Thanks
-k
- 6
- Reflection with Java and Oracle 10gHi everyone,
We have change oracle 8i to oracle 10g, now we have problems with the
reflection in JAVA.
I've got an IllegalAccessException:
Object value;
value = infoResultSetAndData.getResultSetMethodGet().invoke(rs, new
Object[] {new Integer(infoResultSetAndData.getResultSetIndice())});
thanks for suggestions,
fourmi
- 7
- 7
- model to xmlHi,
We have "Objects" that relate to each other in a parent-child
relationship. Also these objects can have references to ther objects
that is not a parent. Let me give you all an example.
I have the following parent-child relationship between objects,
Object A=1
|
-------------
| |
Object B=1 Object C=1
|
-------------
| |
Object D=1 Object D=2
Note: The number is the identity when we have more than one object of
the same type.
"Object A=1" is parent to child "Object B=1".
We have the same relationship for "Object D=1". "Object A=1" is parent
to "Object B=1" which is parent to "Object D=1". The path to "Object
D=1" is "Object A=1,Object C=1,Object D=1".
Also "Object B=1" can have a reference to "Object D=2". The
"reference"-attribute in "Object B=1" has the following path,
"Object A=1,Object C=1,Object D=2"
My question is if there is a tool where I can graphically create my
model ( see my nice one !!!) and from that generate an xml file ( or
xmi).
Requirements:
* It is important that when I create "Object B=1" it must be possible
for "Object B=1" to know that it's parent is
"Object A=1". When the hirarchy grows the child at the end should know
the whole path to itself.
* It is also important that a reference to an Object D=2 is created as
"Object A=1,Object C=1,Object D=2"
Has anyone done something similar? Any open-source tools for this? All
ideas/questions are welcome.
BR
//Mikael
- 9
- a simple java timerJust wondering, has anyone here ever used java.swing.timer if so, have you
got any examples? i cant seem to find many on google :s
- 12
- IndexOf for whitespaceWhat if you wanted the indexOf either a space or a \n whichever came
first. Have you a slick way to code that?
Pedestrian possibilities include:
1. pair of indexOfs , take minimum ignoring <0s.
2. Write a loop that uses charAt
3. write a regex
Is there a slick way to handle it?
--
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
- 12
- Null pointer exception while trying to repaint the component that displays a buffered image when the component is scrolled using scroll barI am trying to repaint a component that displays a buffered image when
the component is scrolled. I get the following error:
[java] java.lang.NullPointerException: NullSD does not handle
this operation
[java] at sun.java2d.NullSurfaceData.getRaster(Unknown Source)
[java] at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(Unknown
Source)
[java] at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown
Source)
[java] at sun.java2d.loops.MaskBlit$General.MaskBlit(Unknown
Source)
[java] at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Unknown
Source)
[java] at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer
$Composite.renderBox(Unknown Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.spanClipLoop(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.renderSpans(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.renderPath(Unknown
Source)
[java] at sun.java2d.pipe.SpanShapeRenderer.fill(Unknown Source)
[java] at sun.java2d.pipe.ValidatePipe.fill(Unknown Source)
[java] at sun.java2d.SunGraphics2D.fill(Unknown Source)
[java] at
i3dea.ditto.DocumentImageDisplay.paintZone(DocumentImageDisplay.java:
256)
[java] at
i3dea.ditto.DocumentImageDisplay.paintComponent(DocumentImageDisplay.java:
467)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JComponent.paintChildren(Unknown Source)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JViewport.paint(Unknown Source)
[java] at javax.swing.JComponent.paintChildren(Unknown Source)
[java] at javax.swing.JComponent.paint(Unknown Source)
[java] at javax.swing.JComponent.paintWithOffscreenBuffer(Unknown
Source)
[java] at javax.swing.JComponent.paintDoubleBuffered(Unknown
Source)
[java] at javax.swing.JComponent._paintImmediately(Unknown
Source)
[java] at javax.swing.JComponent.paintImmediately(Unknown Source)
[java] at javax.swing.RepaintManager.paintDirtyRegions(Unknown
Source)
[java] at javax.swing.SystemEventQueueUtilities
$ComponentWorkRequest.run(Unknown Source)
[java] at java.awt.event.InvocationEvent.dispatch(Unknown Source)
[java] at java.awt.EventQueue.dispatchEvent(Unknown Source)
[java] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
[java] at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[java] at java.awt.EventDispatchThread.run(Unknown Source)
Thanks
Mangai
- 12
- Hibernate on delete cascadeI use Hibernate and I am not able to do cascade delete.
After I create a project I have:
select * from project;
uid | name | shortdescription
-----+------+-----------------
1 | nc | NC Web application
(1 row)
After I subscribe to the project I have:
select * from subscription;
uid | account | project | role
-----+---------+---------+------
1 | 1 | 1 | 1
(1 row)
When I delete the project with a simple session.delete
try {
session.delete(project);
session.flush();
} catch (HibernateException e) {...
the row is deleted in the table "project"
but the row stays in table "subscription". Only the column entry "project" is set to null.
select * from subscription;
uid | account | project | role
-----+---------+---------+------
1 | 1 | | 1
(1 row)
I want the row to be deleted, how do I do that?
My two tables one for Projects and one for Subscriptions
<hibernate-mapping>
<class name="org.cobra.persistence.Project" table="project">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="name">
<column name="name" sql-type="char(32)" not-null="true"/>
</property>
<property name="shortDescription">
<column name="shortDescription" sql-type="char(256)" not-null="true"/>
</property>
<set name="subscriptions" table="subscription" cascade="all-delete-orphan">
<key column="project"/>
<one-to-many class="org.cobra.persistence.Subscription"/>
</set>
<set name="subscriptionsRequested" table="subscriptionRequest" cascade="all-delete-orphan">
<key column="project"/>
<one-to-many class="org.cobra.persistence.SubscriptionRequest"/>
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="org.cobra.persistence.Subscription" table="subscription">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<many-to-one name="account" column="account" cascade="all" class="org.cobra.persistence.Account" />
<many-to-one name="project" column="project" cascade="all" class="org.cobra.persistence.Project" />
<many-to-one name="role" column="role" cascade="all" class="org.cobra.persistence.Role" />
</class>
</hibernate-mapping>
- 13
- question about compiling java with textpadHow do i set a classpath in the javac? its not paying attention to the
classpath I have set at the environment level. This is windows 2000.
I go to configure->preferences->tools->compile java
I see $file in the parameters. Not able to do this:
-classpath <path> $file
and i get the standard javac error where it lists the options.
- 15
- Returning value from deep recursionI have the following code
***********************************
/**
* Recurses through schema finding the first instance of the
element name
* @param schemaElement - current element being compared from
schema
* @param checkElement - element to be checked against i.e. the
node selected in the gui
* @return the element in schema which matches the checkElement
*/
private Element findElementNameMatch(Element schemaElement, Element
checkElement)
{
// Get list of children
List listOfChildren = schemaElement.getChildren();
// If element has children
if(listOfChildren.size() != 0)
{
// Recurse through all elements under this one
for(int x=0; x < listOfChildren.size(); x++)
{
// Get child element
Element childElement = (Element) listOfChildren.get(x);
if(childElement.getName() == checkElement.getName())
{
return(childElement);
}
findElementNameMatch(childElement,checkElement);
}
}
return(null);
}
***********************************
The method is trying to find an element in an xml document that matches
a given name.
Can anyone give me tips on how to go about returning a value from deep
recursion to the first recursion of that particular method, so it can
return that value to the method that called it.
And also quite importantly how to stop any recursions after a match has
been found. EG a target element is found and returned, but how can i
stop the recursion going on to check elements under this element.
So far i have only achieved the two by creating a global variable and
flag, the variable is initialised when the match is found, and flag is
set to true so no more recursions are done afterwards.
- 15
- API 1.5.0 DownloadHi all,
I am new to the Mac and am looking for a download of the
jdk 1.5.0 api. I cannot find a tarball or zip file on the
Sun site that I can download so I can use the reference when
I am offline.
Suggestions?
Thanks,
Bob
- 15
- McDonalds/RoundTable, design&farm (was: I'm still waiting for ...)> From: email***@***.com (Michael Sullivan)
> ... instead of looking for exactly and precisely the kind of work
> that you have done in the distant past, ...
You're displaying a serious misconception. I'm available for any legal
work where I'd be doing something actually useful so that it would be
worth paying me to do it. It's the employers who refuse to even
consider people who haven't done exactly the same kind of work before.
> Go work at McDonalds
I tried that, when I had less than one year work experience. The
manager at the McDonalds on El Monte near El Camino Real told me that
because I have a college degree he won't consider me for employment
because he'd waste two months training me and then I'd find a better
job elsewhere and he'd be out the expense of training. Later that year
I got a job at Round Table Pizza on University in Palo Alto, where a
ditzy redhead Mrs. Masinter wasn't watching where she was going and
collided with my car and then freaked out seeing the car parts strewn
on the pavement, apologizing, exchanging insurance info, then she drove
off before giving me a chance to inspect the damage and see that all
the damage was to *her* car, not mine. Anyway, Round Table fired me
because I suffer a learning disability, unable to memorize the prices
on the menu. A year or two later I was sitting at a terminal at the
A.I. lab doing my usual work for free, and occasionally running FINGER
to see who else was around, when I saw Larry Masinter logged in, so I
wwnt over and asked if he was in any way related to that ditzy driver,
and indeed that was his former wife. He showed me Lisp for the first
time, impressed me, and after Hans Moravec explained the REP loop to me
I was forever going strong with Lisp.
> or a factory
That's not a good idea. I have very poor muscle coordination, can't
write legibly, can't do sports at all, take ten times as long as anyone
else to do a simple mechanical task in metal/wood shop in school and
still the result is cruddy, need extra space on both sides of car when
I'm driving because I can't judge distance between car and parket cars,
break almost anything physical I try to work on, did I tell you about
the disaster when I tried to do work on my car (tune-up, and lubricate
the air-duct wire-in-sleeve control cables)?
> a lot more brainpower goes into defining the problems that explicitly
> than into the actual coding,
Much of my work at Stanford was like that. Unfortunately there's no way
to express that with buzzwords on a resume, so you're not aware of that
from reading my resumes.
> and once you've done that part -- Indians and Chinese can and will
I'd be glad to design the software, farm it out to I&C, then check what
comes back to make sure it does the job that was required. Do you know
any such software-design jobs available now? I've never seen any such
jobs advertised anywhere, ever in all the years since I started
programming.
|
| Author |
Message |
Mike

|
Posted: 2006-4-18 22:28:00 |
Top |
java-programmer, java vs irc
Hi
Im at a crossroad as to how to implement a webchat. I have the option of
building a chat using a standard IRC server saving me the trouble of
implementing it myself, OR i can write the server myself in Java giving me
full customizability. I would tend to go with the latter approach however im
rather concerned about performance. By performance im thinking bandwidth and
server load. So my question is: is it possible to build a chat server in
Java that is
a) better or equal to an IRC server utilizing bandwidth, and
b) better or equal to an IRC servers server load?
Im thinking performance wise that IRC would be better, but im not sure
whether this is true so im asking if anyone can give me some input as to why
one solution would be better than the other.
Thanx
Mike
|
| |
|
| |
 |
Oliver Wong

|
Posted: 2006-4-18 22:32:00 |
Top |
java-programmer >> java vs irc
"Mike" <email***@***.com> wrote in message
news:4444f755$0$16993$email***@***.com...
> Hi
> Im at a crossroad as to how to implement a webchat. I have the option of
> building a chat using a standard IRC server saving me the trouble of
> implementing it myself, OR i can write the server myself in Java giving me
> full customizability. I would tend to go with the latter approach however
> im rather concerned about performance. By performance im thinking
> bandwidth and server load. So my question is: is it possible to build a
> chat server in Java that is
> a) better or equal to an IRC server utilizing bandwidth, and
> b) better or equal to an IRC servers server load?
> Im thinking performance wise that IRC would be better, but im not sure
> whether this is true so im asking if anyone can give me some input as to
> why one solution would be better than the other.
What features do you want that IRC would not already provide?
Have you considered using an IRC server now, and gradually developing a
Java client for the IRC server with some custom extensions?
- Oliver
|
| |
|
| |
 |
Monique Y. Mudama

|
Posted: 2006-4-19 0:36:00 |
Top |
java-programmer >> java vs irc
On 2006-04-18, Mike penned:
> Hi
> Im at a crossroad as to how to implement a webchat. I have the option of
> building a chat using a standard IRC server saving me the trouble of
> implementing it myself, OR i can write the server myself in Java giving me
> full customizability. I would tend to go with the latter approach however im
> rather concerned about performance. By performance im thinking bandwidth and
> server load. So my question is: is it possible to build a chat server in
> Java that is
> a) better or equal to an IRC server utilizing bandwidth, and
> b) better or equal to an IRC servers server load?
> Im thinking performance wise that IRC would be better, but im not sure
> whether this is true so im asking if anyone can give me some input as to why
> one solution would be better than the other.
With so many chat and IM protocols out there, I'm amazed by the number
of people who crop up asking about how to build yet another one.
Unless you have some truly revolutionary capability to add, why do you
want to reinvent the wheel?
--
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-4-19 1:26:00 |
Top |
java-programmer >> java vs irc
On Tue, 18 Apr 2006 10:35:35 -0600, "Monique Y. Mudama"
<email***@***.com> wrote, quoted or indirectly quoted someone who
said :
>With so many chat and IM protocols out there, I'm amazed by the number
>of people who crop up asking about how to build yet another one.
see http://mindprod.com/jgloss/jabber.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Mike

|
Posted: 2006-4-19 2:33:00 |
Top |
java-programmer >> java vs irc
> With so many chat and IM protocols out there, I'm amazed by the number
> of people who crop up asking about how to build yet another one.
> Unless you have some truly revolutionary capability to add, why do you
> want to reinvent the wheel?
Its not so much reinventing the wheel as it is inveting the best wheel for
the vehicle.
Its all about building a system that suits the intent.
Fx. If someone logs on to an IRC server how do i tell the other users what
gender the user has?
Naturally there are ways to get around this issue however im not interested
in making workarounds on an excisting system. But not on the expense of
performance. The system i want to develop has to be scaleable and be able to
support 100.000 users which IRC has proven to handle very well. The question
still remains whether building your own system having the same performance
is feasible.
Mike
|
| |
|
| |
 |
Mike

|
Posted: 2006-4-19 2:42:00 |
Top |
java-programmer >> java vs irc
> What features do you want that IRC would not already provide?
Fx. If someone logs on to an IRC server how do i tell the other users what
gender the user has?
> Have you considered using an IRC server now, and gradually developing a
> Java client for the IRC server with some custom extensions?
Yes and im kinda leaning towards this approach souly because i believe the
performance is better using an existing IRC server end make some extensions.
However i was kinda keen on making my own. Mostly to be able to customize it
as i want it and secondly for the hell of it. Just not on the expense of
performance. It has to be scaleable and be able to support at least 100.000
users. So the questions still remains whether its feasible making your own
server/client chat system using Java.
Mike
|
| |
|
| |
 |
Oliver Wong

|
Posted: 2006-4-19 2:54:00 |
Top |
java-programmer >> java vs irc
"Mike" <email***@***.com> wrote in message
news:444532d8$0$9303$email***@***.com...
>> What features do you want that IRC would not already provide?
>
> Fx. If someone logs on to an IRC server how do i tell the other users what
> gender the user has?
I'd go with a custom Java client layered on top of IRC. So you might
send, for example <logon gender="male"/> into the IRC channel, and the
clients will parse this and do whatever GUI stuff they need to do. Power
users can use "normal" IRC clients and manually send commands to the
channel, so make sure any features you expose don't result in a security
problem (e.g. <makeAdmin user="owong"/>).
>
>> Have you considered using an IRC server now, and gradually developing
>> a Java client for the IRC server with some custom extensions?
>
> Yes and im kinda leaning towards this approach souly because i believe the
> performance is better using an existing IRC server end make some
> extensions.
> However i was kinda keen on making my own. Mostly to be able to customize
> it as i want it and secondly for the hell of it. Just not on the expense
> of performance. It has to be scaleable and be able to support at least
> 100.000 users. So the questions still remains whether its feasible making
> your own server/client chat system using Java.
Yes, it's possible. As to whether your custom Java implementation will
be more performant than an IRC solution you might download, I have no idea.
It probably depends on what hardware you've got, what IRC package you
download, how good a Java programmer you are, what you actually end up
coding, what kind of hardware your users have, etc.
- Oliver
|
| |
|
| |
 |
Monique Y. Mudama

|
Posted: 2006-4-19 3:30:00 |
Top |
java-programmer >> java vs irc
On 2006-04-18, Mike penned:
>> What features do you want that IRC would not already provide?
>
> Fx. If someone logs on to an IRC server how do i tell the other
> users what gender the user has?
Maybe this is just an example to hide your real needs, but as people
play pretend with their genders all the time online, this seems like a
pointless effort to me. There's a reason A/S/L is a joke question
nowadays.
>> Have you considered using an IRC server now, and gradually
>> developing a Java client for the IRC server with some custom
>> extensions?
>
> Yes and im kinda leaning towards this approach souly because i
> believe the performance is better using an existing IRC server end
> make some extensions. However i was kinda keen on making my own.
> Mostly to be able to customize it as i want it and secondly for the
> hell of it. Just not on the expense of performance. It has to be
> scaleable and be able to support at least 100.000 users. So the
> questions still remains whether its feasible making your own
> server/client chat system using Java.
Well, if you just want to do it yourself because you have that itch
and you stand to learn a lot from it, go for it! I do still think
that it would help to use an existing protocol (not necessarily an
existing server), or at least to base your protocol on those that have
gone before.
--
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-4-19 4:14:00 |
Top |
java-programmer >> java vs irc
On Tue, 18 Apr 2006 20:41:38 +0200, "Mike" <email***@***.com> wrote, quoted
or indirectly quoted someone who said :
>Fx. If someone logs on to an IRC server how do i tell the other users what
>gender the user has?
http://mindprod.com/jgloss/images/internet_dog.jpg
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Monique Y. Mudama

|
Posted: 2006-4-19 4:48:00 |
Top |
java-programmer >> java vs irc
On 2006-04-18, Roedy Green penned:
> On Tue, 18 Apr 2006 20:41:38 +0200, "Mike" <email***@***.com> wrote,
> quoted or indirectly quoted someone who said :
>
>>Fx. If someone logs on to an IRC server how do i tell the other
>>users what gender the user has?
>
> http://mindprod.com/jgloss/images/internet_dog.jpg
The requested URL /jgloss/images/internet_dog.jpg was not found on
this server.
--
monique
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
|
| |
|
| |
 |
Roedy Green

|
Posted: 2006-4-19 7:00:00 |
Top |
java-programmer >> java vs irc
On Tue, 18 Apr 2006 20:13:31 GMT, Roedy Green
<email***@***.com> wrote, quoted or
indirectly quoted someone who said :
>http://mindprod.com/jgloss/images/internet_dog.jpg
arrgh. try
http://mindprod.com/images/internet_dog.jpg
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
|
| |
|
| |
 |
Lion-O

|
Posted: 2006-4-19 7:49:00 |
Top |
java-programmer >> java vs irc
> So my question is: is it possible to build a chat server in
> Java that is
> a) better or equal to an IRC server utilizing bandwidth, and
I sincerely doubt this.
> b) better or equal to an IRC servers server load?
Idemditto.
Don't forget that many IRC servers have experienced years of development and
testing in both the theoretical approach and in the field. I really think that
in that respect it would be the wrong way to approach this since you're likely
to end up facing bigger problems and more developing than is needed.
Instead I'd focus on an existing IRCd to suit your need (unreal, ircu, dancer,
bahamut.. to name but a few.) and work from there. There are many good IRC
services which allow you to "extend" your IRC experience, especially now that a
lot of them have started utilizing a modulair approach (my main experience is
with Anope) thus allowing you to extend the features you might need if needed.
After you have these features setup your applet can easily do its work as a
front end. IMO the best approach.
Still, if you really need fine-grain control and wish to stick to Java I'd
consider checking out PircBot to write a very specific Java bot which can
directly support all the features you wish to support by allowing your frontend
to contact your bot directly. From what I read in the thread so far I think a
bot, connected to a seperate IRC server, should be all you need to allow
storing/retrieving whatever kind of information you wish.
Another advantage of using this approach is that the so called "power users"
(as mentioned somewhere in the thread) would never be hindered in their
chatting by all sorts of weird messages popping up around channels (like ms
chat does) since your applet will talk directly to a main "information source".
The only thing I'd keep in mind with that setup is to make the bot also
manually usable so that people can still get information from it without using
a front-end.
--
Groetjes, Peter
.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc
|
| |
|
| |
 |
Greg R. Broderick

|
Posted: 2006-4-19 7:50:00 |
Top |
java-programmer >> java vs irc
"Monique Y. Mudama" <email***@***.com> wrote in
news:email***@***.com:
> On 2006-04-18, Roedy Green penned:
>> On Tue, 18 Apr 2006 20:41:38 +0200, "Mike" <email***@***.com> wrote, quoted
>> or indirectly quoted someone who said :
>>
>>>Fx. If someone logs on to an IRC server how do i tell the other users
>>>what gender the user has?
>>
>> http://mindprod.com/jgloss/images/internet_dog.jpg
>
>
> The requested URL /jgloss/images/internet_dog.jpg was not found on
> this server.
This gets the point across just as well:
http://www.thinkgeek.com/oreilly/tshirts/605c/back/
:-)
|
| |
|
| |
 |
Mike

|
Posted: 2006-4-19 20:40:00 |
Top |
java-programmer >> java vs irc
> Maybe this is just an example to hide your real needs, but as people
> play pretend with their genders all the time online, this seems like a
> pointless effort to me. There's a reason A/S/L is a joke question
> nowadays.
That was just an example. The intent is building a Java client that is able
to display avatars based on gender, admin rights and so on. I'm not really
concerned whether the user is being truthfull or not
Mike.
|
| |
|
| |
 |
Mike

|
Posted: 2006-4-20 4:39:00 |
Top |
java-programmer >> java vs irc
> Don't forget that many IRC servers have experienced years of development
> and
> testing in both the theoretical approach and in the field. I really think
> that
> in that respect it would be the wrong way to approach this since you're
> likely
> to end up facing bigger problems and more developing than is needed.
>
> Instead I'd focus on an existing IRCd to suit your need (unreal, ircu,
> dancer,
> bahamut.. to name but a few.) and work from there. There are many good
> IRC
> services which allow you to "extend" your IRC experience, especially now
> that a
> lot of them have started utilizing a modulair approach (my main experience
> is
> with Anope) thus allowing you to extend the features you might need if
> needed.
>
> After you have these features setup your applet can easily do its work as
> a
> front end. IMO the best approach.
>
> Still, if you really need fine-grain control and wish to stick to Java I'd
> consider checking out PircBot to write a very specific Java bot which can
> directly support all the features you wish to support by allowing your
> frontend
> to contact your bot directly. From what I read in the thread so far I
> think a
> bot, connected to a seperate IRC server, should be all you need to allow
> storing/retrieving whatever kind of information you wish.
>
> Another advantage of using this approach is that the so called "power
> users"
> (as mentioned somewhere in the thread) would never be hindered in their
> chatting by all sorts of weird messages popping up around channels (like
> ms
> chat does) since your applet will talk directly to a main "information
> source".
>
> The only thing I'd keep in mind with that setup is to make the bot also
> manually usable so that people can still get information from it without
> using
> a front-end.
You pose some interesting solutions that i will look in to. Thank you for
your very insightful answer.
Mike.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- instanceof strange behaviourHi there.
I have a problem that consists of the following.
In my class, I have a method named getNativePreparedStatement that
receives a parameter of the type PreparedStatement:
private PreparedStatement getNativePreparedStatement(PreparedStatement
ps)
I pass to this method a non null object of the type:
org.apache.commons.dbcp.DelegatingPreparedStatement
Inside this method, I do a conditional instruction like this:
if(ps instanceof DelegatingPreparedStatement){
//some code here
}
What happens is that in the if instruction the instanceof operator does
not recognize the object ps as a DelegatingPreparedStatement object.
Now, I am sure ps is of the type DelegatingPreparedStatement.
Does anyone have some clue why this happens?
I am running this application under the Apache Tomcat application
server and I am using struts.
Regards,
LA
- 2
- AXIS attachment problemHi,
Currently i tried to make attachment with AXIS .
I have following error message
Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoService
faultSubcode:
faultString: The AXIS engine could not find a target service to invoke! target
Service is null
faultActor:
faultNode:
faultDetail:
I think i could resolve my problem if i found a little attachment sample ?
Where could i found it, or a tutorial ?
Regards
Philippe
- 3
- static reference in a non-static methodI'm trying to run a simple program that read info from a file and
displays it on the screen. However, I am constantly getting the
following error.
==================================================================================
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
Cannot make a static reference to the non-static field tokenizer
Cannot make a static reference to the non-static field tokenizer
==================================================================================
I don't want to declare any variables static since I don't think I
need to. My code is given below.
================================================================
File myFile = new File("Info.txt");
Scanner tokenizer = new Scanner(myFile);
String str = null;
public static void main(String[] args)
{
while (tokenizer.hasNextLine())
{
System.out.println(tokenizer.next());
}
}
=========================================================================
I was getting a similar error when I was trying to read in standard
input from the user i.e. using input stream reader and buffer
reader.
Can anyone please help?
- 4
- Exiting a class in the middleI am working on a multi-threaded server-socket application. I already
have lots of crazy loops which are needed in order to function
properly.
What I need to add is a function that once all the people logged-on
exited, the server would be ready to accept connections again.
IS THERE A COMMAND THAT WOULD BREAK THROUGH THE CLASS AND EXIT IT
ANYWHERE TO GO BACK TO THE CLASS, WHICH CALLED IT (IN MY CASE BACK TO
MAIN).
I tried Label:
continue Label;
but I really do have messy loops that won't let this work properly.
I also thought maybe "System.exit(1);" would work, but that terminates
the whole application.
Any suggestions would be very appreciated.
Little BrainC
- 5
- pornn piictures!
contentt!
http://thecowboyfft.com
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 6
- JGoodies JLabel with multiple linesHi
I use JGoodies Forms to create a GUI application. I need to show a simple
multiline description in the window. I use JLabel with html text like
"<HTML> ... my description ... </HTML>".
Because it's multiline, java never knows how much lines it contains and what
is initial height of that component. When I add this do panel and show on
the screen, my frame has to small height and hides some components. General
problem is that I use different fonts (almst blind user can select bigger
fonts).
code:
-------------------------------
FormLayout layout = new FormLayout("fill:500px", // kolumny
"p, 10px, p, 10px, p, 7px, p, 7px, p, 10px, p"); //
wiersze
PanelBuilder builder = new PanelBuilder(layout);
builder.setDefaultDialogBorder();
CellConstraints cc = new CellConstraints();
...........
builder.add(textArea, cc.xy(1,3));
...........
getContentPane().add(builder.getPanel());
pack();
Can anyone help me ?
Tom
- 7
- Is this a ZipInputStream Bug?
I just got thru tracking down what was happening, but I still don't know
WHY.
Im using ZipInput & Output Stream classes to make a compressed file
(actually it's an image). I create it via ZipOutputStream using a 1K
buffer for writing i.e.:
...
try { // Create the ZIP file
zos = new ZipOutputStream(new FileOutputStream(zipfname)); }
catch (IOException e) {
System.out.println("ZipOutputStream error on open.");
return null; }
try { zos.putNextEntry(new ZipEntry(imgfname)); }
catch (IOException e) {
System.out.println("ZipOutputStream error on put-entry.");
return null; }
...
try { zos.write(bbuf, 0, bix); }
catch(IOException e) {
System.out.println("ZipOutputStream error on write.");
error = true;
break;
}
...
Here bbuf is 1K.
All is ok - WinZip can extract it and the image is fine. Then I try to
read it back via ZipInputStream - i.e.:
...
try { zis = new ZipInputStream(new FileInputStream(filespec)); }
catch (IOException e) {
System.out.println("ZipInputStream error on open.");
return pixels; }
try { zent = zis.getNextEntry(); }
catch (IOException e) {
System.out.println("ZipInputStream error on get-entry.");
return pixels; }
...
while ( cnt > 0 ) {
try { rcnt = zis.read(bbuf, rcnt, cnt); }
catch(IOException ex) {
System.out.println("ex: " +ex.getMessage());
error = true; }
cnt -= rcnt;
}
...
Here is where the problem occurs. If bbuf is 128 or 256 bytes the image
returns just like it should. But if I increase it to 1K junk starts to
show up within the picture at 4K the picture is barely viewable because
of the junk and at 32K I get ArrayOutOfBounds exception during the read
(NOT related to my code). I've verified that the "junk" is data that did
not come out of the zip, the way it went in.
I'm running JDK 1.3.1 on an NT4.0 platform.
Have others seen this behavior ?
Any ideas on why ?
TIA
Don Sykes
- 8
- Need some assistance pleaseHello everyone! I am trying to learn java and have run into kind of a
snag. Here is the code that I have so far:
------ <begin_code> ----------
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.awt.Graphics;
public class Rectangles {
public static void main ( String args[] ) {
// Variables to hold the users input
String number1;
String number2;
String number3;
String number4;
int x;
int y;
int width;
int height;
nextRect: // Continue point for drawing another Rectangle
// Gather input and parse into integers
number1 = JOptionPane.showInputDialog(null, "Please input the x value: ");
number2 = JOptionPane.showInputDialog(null, "Please input the y value: ");
number3 = JOptionPane.showInputDialog(null, "Please input the width
value: ");
number4 = JOptionPane.showInputDialog(null, "Please input the height
value: ");
x = Integer.parseInt(number1);
y = Integer.parseInt(number2);
width = Integer.parseInt(number3);
height = Integer.parseInt(number4);
public void paint( Graphics g )
{
super.paint(g);
g.drawRect(x, y, width, height);
String answer;
answer = JOptionPane.showInputDialog(null, "Would you like to draw
another rectangle? ");
if ( answer == "yes | y")
continue nextRec; // go to nextRec and start over
else
System.exit(0);
}
}
}
------ </end_code> --------
Now, the problem I am having, is I am getting an error between the 't' and
the '(' in "public void paint( Graphics g )" Please be kind in your
comments and keep in mind that I am just learning. If I am trying to do
something that I shouldn't please let me know. I would really like to
know why this won't work.
Thank you in advance!
Regards,
jlk
- 9
- programming the JVMHi,
I'm wanting to program the JVM independant of a compiler by
emitting bytecodes directly and I have orderd the book by J Engel
'Programming for the JVM'.
The lead on this book from amazon is 4-6 weeks which (may?) turn
into never. Does anyone here have recommendations for alternate
texts (that are introductory/tutorial in nature, rather than
reference texts) and websites that may help me with this - so
I don't just sit kicking my heels while it possibly doesn't arrive?
I've hunted in most of the obvious places but nothing seems to
fit the need or cover the topics that the Engel book does
sensibly.
TIA
Chris
- 10
- sysdeo plugin for tomcat/eclipse gone?Hello,
does anybody still have a copy of the latest pluging of sysdeo for
tomcat/eclipse integration? The link to
http://www.sysdeo.com/eclipse/tomcatPlugin.html
does not work anymore...
And I really liked this integration.
Thanks for hints.
- 11
- ports/81272: JDK 1.5 port doesn't build.Synopsis: JDK 1.5 port doesn't build.
Responsible-Changed-From-To: freebsd-amd64->freebsd-java
Responsible-Changed-By: arved
Responsible-Changed-When: Fri Nov 25 16:57:03 GMT 2005
Responsible-Changed-Why:
Refile, this looks like a ports issue.
Assign to port maintainers
http://www.freebsd.org/cgi/query-pr.cgi?pr=81272
- 12
- starting a weblogic servlet?Hello,
I have written a basic servlet of the form
public final class MyServlet extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config)
/* do other stuff */
}
}
My question is, what do I need to do so that the "init" method is
invoked upon servlet (i.e. Weblogic) startup? I'm using Weblogic 5.1
sp 12 on Sun Solaris.
Thanks for your help, - Dave
- 13
- Doctors Use This Too SSBfa5
"Ci-ialis Softabs" is better than Pfizer Viiagrra
and normal Ci-ialis because:
- Guaaraantees 36 hours lasting
- Safe to take, no side effects at all
- Boost and increase se-xual performance
- Haarder e-rectiions and quick recharge
- Proven and certified by experts and doctors
- only $3.99 per tabs
Cllick heree:
http://ossifies.com/cs/?ronn
o-ut of mai-lling lisst:
http://ossifies.com/rm.php?ronn
eD
--
To UNSUBSCRIBE, email to email***@***.com
with a subject of "unsubscribe". Trouble? Contact email***@***.com
- 14
- java and XMLHi
I have the following bit of Java code:
//Use JTidy implementation to create an empty Document object
Document doc = tidy.createEmptyDocument();
//bodyElement is the body element in an HTML Document
Node first = bodyElement.getFirstChild();
Node top = doc.getDocumentElement();
top.appendChild(first);
which produces unexpected results. Basically, all I am trying to do is
retrieve the first child node contained in the body element and copy it to
the new document element. But what I get is the required element AND every
element after it - every one of the first elements siblings! I have tried so
many variations of the above, using DocumentFragments etc, but with no joy.
In order to preserve the little hair I have left, I would be grateful for
any help
Tony
- 15
- Changing Tomcat configurationHello everyone having a slight issue with the java.home variable for
tomcat. It is pointing at the JRE instead of the JDK and I have no idea
where it is set at. If anyone knows where I can change it please inform me.
Thanks,
Jerry
|
|
|