Home pageFind It!Contact PJAPJA documentation

PJA

 PJA Toolkit forum

This forum is dedicated to PJA Toolkit.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject Simple example??

Craig

Location : Cincinnati
Member since : Jun 18, 2003
Messages : 2
 Jun 18, 2003 at 9:35 PM
I am very much looking forward to using PJA Toolkit and the documentation looks great. However, I hate to read documentation unless I absolutely have to. :)

Is there a simple example (like the java tutorials on sun's site) that walks you through the creation of a webpage that displays, say, a circle generated by PJA Toolkit? OR have I missed something in the documentation because nothing is jumping right out at me.

Thanks!

Craig

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 19, 2003 at 12:40 AM
A simple example could be :
------
<%@ page contentType="image/jpeg"
import="java.awt.image.*,java.awt.*,com.sun.image.codec.jpeg.*" %>
<% // Create an offscreen image 100 x 100 pixels
BufferedImage image = new BufferedImage (100, 100, BufferedImage.TYPE_INT_RGB);
// Draw into the image a black circle with the text Hello on a yellow background
Graphics g = image.getGraphics();
g.setColor (Color.yellow);
g.fillRect (0, 0, 100, 100);
g.setColor (Color.black);
g.drawOval (0, 0, 99, 99);
g.drawString ("Hello", 30, 50);
// Create a JPEG encoder to send the image at JPEG format
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
encoder.encode(image);
response.getOutputStream().close (); %>
------
Copy this code in a JSP file named for example test.jsp, put it on your web server and test it.

If your server has no X11 DISPLAY, there sould be error that says :
------
Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
------
In that case, you may use PJA Toolkit to make it work. All you have to do is specifying the java command following options (with correct paths) :
------
-Xbootclasspath/a:/path/to/pja.jar
-Dawt.toolkit=com.eteks.awt.PJAToolkit
-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment
-Djava.awt.fonts=/path/to/jdk/jre/lib/fonts
------
If you use Tomcat 4.1, these options may be set in the environment variable JAVA_OPTS. For other web servers have a look at the other messages on this forum or try a search on google.
---
Manu (moderator/modérateur)

Peyman

Member since : Sep 4, 2003
Messages : 1
 Sep 4, 2003 at 8:14 PM
I did exactly as mentioned in the example above but my Weblogic server coredumps...when I remove the -Xbootclasspath/a:/path/to/pja.jar it doesn't coredump but then it can't find PJAGraphicsEnvironment...has anyone run into this before?

Using JDK 1.3, Weblogic 5.10

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Sep 9, 2003 at 8:49 AM
Do you have any stack trace ?
Try to apply the patch described in the FAQ "Why the Java Virtual Machine crashes when I use fonts on UNIX platform ?"
---
Manu (moderator/modérateur)

rodrodriguez

Member since : Dec 26, 2003
Messages : 2
 Dec 26, 2003 at 11:42 PM
Specify on BOOTCLASSPATH not only pja.jar but rt.jar and jsse.jar also.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jan 7, 2004 at 12:23 AM
Repeating rt.jar is normaly not necessary, as the /a part of the -Xbootclasspath/a option is supposed to append any library to the default bootclasspath that always includes rt.jar...
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2014 eTeks - All rights reserved

PJAPJA documentation