• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

HOWTO: Avatars on a headless server

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many of you may be deploying your JForum on a headless server. If so, you may discover that you get an error whenever you attempt to upload an avatar.

The problem is that the Java AWT code is attempting to draw the avatar (I believe in order to convert it into a PNG image). In turn, the AWT package is causing the X11 server to open the DISPLAY.

In this case, you will see an error message similar to:

To correct this problem, you need to tell the Java AWT package that the X11 server is headless and has no display. This is done by setting a System Property in the JVM when you start Tomcat (or your appserver of choice).

The property you need to set is: java.awt.headless
The property needs to be set to: true
The way you set this property is to invoke the JVM with the following option: -Djava.awt.headless=true

If you are using Tomcat, the simplest way to accomplish this is to add the following like to your <tomcat>/bin/setenv.sh file:


This will properly send the -D option to the JVM when tomcat starts up.

PLEASE NOTE: This solution will ONLY work with JDK1.4 or later. For those who are stuck with JDK1.3, you will need another solution involving X servers designed for headless operation. A Google search will find the answer for you. Search for "tomcat open display :0.0", and you will find many references.
[originally posted on jforum.net by time]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great dude, thanks for the post

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anonymous wrote:Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.



Hm, interesting.. I'll take a closer look

Thanks,
Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anonymous wrote:Sorry, but i now solution for JDK 1.3 platform. In this case just use Pure Java AWT (http://www.eteks.com/pja/en/). You must download and install this toolkit only.


Really interesting, since my hosting provider doesn't allow an headless environment.
[originally posted on jforum.net by jamesyong]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The difference between phpBB and JForum is that you try to convert all images (avatars) to PNG format - so some unsupported PNG formats would be not correctly converted, and animated GIFs would not be converted to MNGs (very few browsers have support for the animated PNG, or MNG format, and java.image has no support for MNG).
What is the reason for converting all images to PNG format instead of leaving them alone?
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can leave the original gif if the image is smaller than the maximum size allowed by the board ( configurable via the admin panel )..

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.


As I know, Unisys patent for GIF/LZW technology has expired. Now you could freely output graphs to GIF/TIFF image formats in the desktop applications.
see this http://cloanto.com/users/mcb/19950127giflzw.html
[originally posted on jforum.net by andowson]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have u never tried to use the this api: https://jai.dev.java.net/ ?
[originally posted on jforum.net by 0m4r]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

0m4r wrote:have u never tried to use the this api: https://jai.dev.java.net/ ?



Nope.. I'll take a look.

Other main problem with regular JDK 1.4 image classes is that they are SO SLOW.

Raael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Steil wrote:I can leave the original gif if the image is smaller than the maximum size allowed by the board ( configurable via the admin panel )..

The problem is when we need to resize the image, since javax.imageio does not supporint writing of GIF files due to licensing problems.

Rafael



The simplest solution would be to analyse the size (in bytes and in width/height) using some image classes (I know for example http://reader.imagero.com/) and display an error if it is too big. Then the user could resize his/her image as he/she likes it.

just my 2���ct.

Greets,
Christian
[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I did to my tomcat5.conf file - it is simpler.#



the file is /etc/tomcat5/tomcat5.conf

Works fine.

Kev
[originally posted on jforum.net by kpassey]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Steil wrote:

0m4r wrote:have u never tried to use the this api: https://jai.dev.java.net/ ?



Nope.. I'll take a look.

Other main problem with regular JDK 1.4 image classes is that they are SO SLOW.

Raael



I have done a bunch with JAI and let me tell you it is NOT FUN. I really don't think you want to go there.

I have found that JDK 1.5's image handling is reasonably good, probably as fast as any other options. JForum is doing exactly the right thing: convert them all to PNGs. Come on, it's 2006 already, PNGs are old news.

As for the headless server issue: This is not a problem at all on Java 1.5. You don't need to set anything. Yes in the old days AWT had difficulties dealing with images with no display available, but those days are long over.

Java 1.5 is two years old. Upgrading is painless. It runs faster and starts faster. Tomcat 5.5 is designed for Java 1.5. Wasting time trying to get stuff to run on older JVMs is just that: a waste of time. Java 6 is due out in a few months.

My big question is: When can we run JForum and Tomcat in a pure open Java implementation? In other words, when can we compile all this stuff with gcj/GNU CLASSPATH and have it run without any Sun Java? I realize that's a big question, because Tomcat itself is not yet supported with gcj, but it's coming sometime this year.

By the way, our JForum powered site is really doing well. In two days we've had 66 new members and 50,000 hits:

http://californiaccw.org

I'm very impressed by the software. I did take out the link back to JForum from the templates, but I put in some big text on the front page, and made a few forum posts about how great JForum is. At some point I'll create a whole page where I go through and describe all the software components that go into it: Linux, Tomcat, Java, JForum, etc.

[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting to know that as of JDK 1.5 java.awt.headless is not needed anymore. That's very good.

About the gcj question: I really don't know; never tried to make such test. But for the little I know about gcj, it should compile JForum without any problems.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Steil wrote:Interesting to know that as of JDK 1.5 java.awt.headless is not needed anymore. That's very good.

About the gcj question: I really don't know; never tried to make such test. But for the little I know about gcj, it should compile JForum without any problems.
l



Tomcat doesn't yet run in gcj, so it will be some time before this whole setup can run in gcj. I just tried to compile the latest Postgres JDBC jar and it also does not compile in gcj, so there are some things to be fixed.

Again I strongly recommend using 1.5 if you aren't already.

Our forum now has over a hundred users and has had over 100,000 hits in the first week of operations. JForum is cool!

[originally posted on jforum.net by Anonymous]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can leave the original gif if the image is smaller than the maximum size allowed by the board in photoshop
kelvin

Baby Gear
[originally posted on jforum.net by kelvin]
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic