Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java and JPEG on X11 displays

Status
Not open for further replies.

pcarver

Technical User
Aug 23, 2001
36
US
It appears that in the Java 1.3 JRE, the JPEG encoder does not work without an X11 display/server. If you try to run a Java program from outside of X, you will get an exception trying to do something with opening up the X11 display.

After a lot of searching and work, it came down to three options:

1) Upgrade to Java JRE 1.4 Beta 2 - Sun has told me that 1.4 fixes this, but it is just a beta and doesn't appear the first customer ship will occur until late 2001. Plus, I also use J2EE and didn't think it was going to be compatible with JRE 1.4 at this time

2) Use a 3rd party Java AWT library that is not dependent on X. Once such package that everyone talks about is the PJA toolkit at This does require either changes to your java compile/run commands and/or actual code. I didn't want to change code and never could seem to get all these strange java run command-line options to work...so I opted out for this.

3) Run a background X server and make sure your java program has a virtual display. This it the route I finally took and it seems to be doing ok (but I've only ran this configuration for a week now). This is what I did:

- From the RedHat CD, I install the Xvfb virtual X server
- From the console, did:
export DISPLAY=localhost:1.0
Xvfb :1 -screen 0 1600x1200x8 &
- executed my Java application from the console

Bingo, it worked. In my case, it was a bit more complicated since I had to do this from Tomcat/servlet; I had to modify the tomcat startup script to do the above export/Xvfb command prior to spawning the tomcat daemon. But, it still seems to work. I don't know how this thing is going to react when I do simultaneous user testing.

Hope this helps someone.

/paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top