Location : Cincinnati
Member since : Jun 18, 2003
Messages : 2
| Jul 4, 2003 at 10:12 PM
i tried the "simple example" below in this list (thanks!) and get this error:
javax.servlet.ServletException: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
this happens the first time. after that, i get the http 500 error stating the page could not be loaded. not to be stating the obvious, but the error message states the AWT library cannot be found. why then the http error? is this generally the case on JSP servers running tomcat? i am attempting to get my ISP to get these issues worked out and any insight from you would be well appreciated.
Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
| Jul 4, 2003 at 11:42 PM
Even if you use PJA, some AWT classes still require some X11 libs to be installed on the server to be able to run. Please read http://www.eteks.com/pja/en/forum/viewSubject.jsp?subjectId=38 for more information.
If your ISP refuse to install the basic X11 libs, you can still create images using directly the com.eteks.awt.PJAImage and com.eteks.awt.PJAGraphics classes, as shown in this example that shows the same image as the example at http://www.eteks.com/pja/en/forum/viewSubject.jsp?subjectId=51 :
<%@ page contentType="image/gif"
<% // Set the directory where .pjaf fonts are stored
System.setProperty ("java.awt.fonts", "path/to/fontdirs");
// Create an offscreen image 100 x 100 pixels
PJAImage image = new PJAImage (100, 100);
// Draw into the image a black circle with the text Hello on a yellow background
PJAGraphics g = (PJAGraphics)image.getGraphics();
// Change color to yellow without java.awt.Color class
g.setColor (255, 255, 0);
g.fillRect (0, 0, 100, 100);
g.setColor (0, 0, 0);
g.drawOval (0, 0, 99, 99);
g.drawString ("Hello", 30, 50);
// Create a GIF encoder with no reference to ColorModel
new GifEncoderNoCM (image, response.getOutputStream()).encode ();
response.getOutputStream().close (); %>
In that case, you can't use the classes java.awt.Toolkit, java.awt.Color, java.awt.Rectangle, java.awt.Font, java.awt.FontMetrics, java.awt.image.ColorModel because they require the X11 libs. com.eteks.awt.PJAGraphics class has some additional methods to be able to draw without these AWT classes : these methods come from the com.eteks.awt.PJAGraphicsExtension interface (http://www.eteks.com/pja/doc/com/eteks/awt/PJAGraphicsExtension.html ) that PJAGraphics implements.
You'll have also to create at least a .pjaf font file with PJAFFontCapture and put this file in the current user directory or in the directory discribed by the java.awt.fonts System property.