Help coderanch get a
new server
by contributing to the fundraiser

Petr Blahos

Ranch Hand
+ Follow
since Apr 28, 2004
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Petr Blahos

You have the right idea, but you must run your method in a thread.
The best thing to do is probably to google for: java swing threads and
read whatever you have found on If you only have one
thread and are running the method in an event handler, you
button-pressed event will be processed AFTER the method finishes. But
it sort of isn't visible from your description.

19 years ago
Well, anyway, if anybody is interested, you can see the
smallest tetris I could write here:

19 years ago
Well, I have never tried this, but what about using System.setErr and
System.setOut to send output to your own PrintStream instead of to

19 years ago
Hi Priya,

It is quite easy, but it is a lot of work. ocx file is in fact
a dll, which is just a PE executable containing resources. You
must parse the content of the file, get the resources section,
find version info and read it. The texts describing the structure
of the files are:

Then you will need to parse the structure of the resources section.
For that, use windows header files, or if you don't have platform
SDK, I think you can successfully use Wine (

Good luck!
19 years ago
Just out of curiosity, what HW and OS is the server? S390?

If you could run at least a web-client of the clients, you could have a web application. It is something different to handle 200 network connections than 200 processes.

Best of luck,
19 years ago
My estimation would be that you don't have much chance here. Even if you reduced the amount of memory needed to 1/2, which is 10M per process, still, 200 times, it is, like, well, a lot. Considering also overhead with managing so many processes, I would say that the system will become unresponsive long before 200 users log in.

If the clients are capable of running java, run it on clients, otherwise, it pretty much depends on the type of the application.

19 years ago
Hi Nagarajan,

That's very easy. The less you tell us, the less of an answer you can expect.

Is the client written with Swing or the server? The data server keeps about clients: are they somehow related to swing? Or do clients run on the same computer as servers? I somehow fail to see relationship between your server, your clients, swing and memory consumption.

You can't call swing from JSP because it is java SERVER pages and you scaresly have a monitor connected to a server. If you want to see a swing application in client's web server, you will have to write an applet (or a client application). I think there is an example of an applet in Tomcat.

Best regards,
19 years ago
Hi all,

I have just finished my submission to Java 4K Game Programming Contest ( - a tetris. You can check it out here:

Anyway, it made me think what size would the smallest possible tetris in java be. If we define rules as follows:
* Size of class files + any possible data files count.
* If there are data files, they must be acquired using CLASS.class.getClassLoader().getResourceAsSream() - or similar, so that it would run both from a jar and from a directory.
* Neither colors nor sizes are important (though presumably it shouldn't be unplayable due to un-visibility).
* It should display score and level and a next item. It must be clear that the displayed Score and Level are score and level.
* The level (of difficulty) should increate with a certain number of removed lines.
* It should implement a keyboard control, up-key will rotate, left, right is obvious.
* Down-key will cause cause the block to either fall down immediatelly or to fall faster. It is kept on the discretion of the implementor, as long as it does something reasonable.
* It should implement a "game over". Then, the space-bar will start a new game. There is no need to let user know that the game ended, neither that they must press space.
* It should be written in Java (not Jython, java assembler, ...).

I have pushed it down to 3536B class file and 224B data file, compiled with jdk-1.4.2_03. What about you?

I don't want to distract you by my solution so I will post it in couple of days time. Just to give you time to think... ;-)

[ February 22, 2005: Message edited by: Petr Blahos ]
19 years ago

is a label.

19 years ago

>I can concatenate the full path to the file name and store it(i dont like this idea.)

This is the best you can do. It is actually a good idea because
it is correct. Java does not know anything about current working
directory. Your request to open a "filename" is just passed to
the OS and it will do whatever it can.

the problem may be too simple but trust me i really need help.

If you yourself percieve that this problem may be too simple,
it should stop you from posting it in advanced forum.

[ February 18, 2005: Message edited by: Petr Blahos ]
19 years ago
Listen Shweta, why don't you write and compile it on Windows and
run on Linux? True, for many people (and I am one of them) the
user-friendlyness of Linux desktop is superior, but it has a learning
curve and you better use what you are comfortable with. You
definitely, can't expect to be comfortable with Linux tomorrow.

Just wondering: these commands "write" and "make" to create an empty
file with, you saw them in any version on vi? Or in Windows?!?

19 years ago
Well, I don't know about this Daemon, but there is another
project called JavaService. That one is used by tomcat4. If
you download the sources you will see how it is done (it would
probably be sufficient to get this JavaService package).
Basically you specify a class to run to start a service and
another one to stop a service when installing. AFAIK windows
will wait until it is finished when stopping, but who are we
to know?

19 years ago

Are you talking about Unix or Windows or something else?
Anyhow, the best way is to go along with OS ways. In WindowsNT+
it would be something like "net stop service_name", in most
linuxes "/etc/init.d/service_name stop" on other unixes

These methods expect that the service CAN be properly stopped

19 years ago
I was wondering how you guys would print a byte, to a stream or
writer as 2 hexadecimal digits? Or more precisely, a byte array
as a sequence of hexadecimal digits? Without big cats (must run
on java-1.4.2 or older)?

I have been looking at formatters for a bit, but it seems to me
that the easiest way would be just to take one half-byte after
another and convert them to a digits manually.

Any thoughts?

Thanks, Petr
19 years ago
I think this topic is very nicely covered in:

BTW, we have a forum here, which is called Swing/AWT/SWT/JFace.

19 years ago