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 Are X11 libs required to run PJA ?

jmennear

Member since : Jun 10, 2003
Messages : 5
 Jun 11, 2003 at 3:39 AM
Here is what I tried:

System.setProperty ("java.awt.fonts", getServletContext ().getRealPath ("/servlet"));

I saw in an earlier message that I might need the X11 lib's. Is that what I should be doing instead of setting the system property.

Running sdk 1.3.1 on my Solaris box.

[Subject changed by moderator]

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 11, 2003 at 9:49 AM
Basic X11 libs like libX11.so or libXt.so are required to run some java.awt classes like java.awt.Color or java.awt.Font. Running a line as simple as
Color c = Color.white;
in your program will require X11 libs (but not a running X11 server), and PJA can't change anything to that because of the static initializer of java.awt.Color class. You'll have to set the java.awt.fonts, awt.toolkit, java.awt.graphicsenv properties too if you want to use PJA.
If ever you really don't want to install X11, you won't be able to run the following classes : java.awt.Toolkit
java.awt.Color
java.awt.Rectangle
java.awt.Font
java.awt.FontMetrics
java.awt.image.ColorModel
By chance, you'll still be able to run java.awt.Image or java.awt.Graphics and their subclasses com.eteks.awt.PJAImage, com.eteks.awt.PJAGraphics. That allows you to create buffered images using only PJA classes ; please see PJADemo.java for an example...
---
Manu (moderator/modérateur)

jmennear

Member since : Jun 10, 2003
Messages : 5
 Jun 11, 2003 at 3:02 PM
I've found the TrueType fonts directory on my solaris box, so, I've changed the setProperties lines to the following:

System.setProperty ("awt.toolkit", "com.eteks.awt.PJAToolkit");
System.setProperty ("java.awt.graphicsenv", "com.eteks.java2d.PJAGraphicsEnvironment");
System.setProperty ("java.awt.fonts", "/usr/openwin/lib/X11/fonts/TrueType/");

Still, I see this error message.

Error: Could not find class: com.eteks.java2d.PJAGraphicsEnvironment
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:61)
at java.awt.Font.initializeFont(Font.java:264)
at java.awt.Font.<init>(Font.java:298)

Can you suggest any action that can help me to overcome this problem.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 11, 2003 at 4:03 PM
pja.jar must be added to bootclasspath thanks to the java option -Xbootclasspath/a:path/to/pja.jar
---
Manu (moderator/modérateur)

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 12, 2003 at 10:36 AM
For your information, after the base system installation of a Debian Linux Distribution described at http://www.debian.org/releases/stable/i386/install.html I had to install the 3 following packages with the dselect tool to make PJA Toolkit work in replacement of the default Java toolkit :
- xfree86-common
- libfreetype6
- xlibs

(You may also install these 3 packages with the command : apt-get install xlibs)

This will install files that can be found in the following directories :
/etc/X11/
/etc/X11/Xresources/
/etc/X11/Xsession.d/
/usr/X11R6/
/usr/X11R6/include/
/usr/X11R6/include/X11/
/usr/X11R6/include/X11/bitmaps/
/usr/X11R6/include/X11/pixmaps/
/usr/X11R6/lib/
/usr/X11R6/lib/X11/
/usr/X11R6/lib/X11/locale/
/usr/X11R6/man/
/usr/X11R6/man/man1/
/usr/X11R6/man/man7/
/usr/share/doc/xfree86-common
and symbolic links to the previous directories :
/usr/bin/X11
/usr/include/X11
/usr/lib/X11
---
Manu (moderator/modérateur)

jmennear

Member since : Jun 10, 2003
Messages : 5
 Jun 30, 2003 at 6:56 PM
When I run the app on my Solaris box I get this in tomcat.log:

Could not find class: com.eteks.java2d.PJAGraphicsEnvironment
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:61)
at java.awt.Font.initializeFont(Font.java:264)
at java.awt.Font.<init>(Font.java:298)
at org.jfree.chart.axis.AxisConstants.<clinit>(Unknown Source)
at org.jfree.chart.axis.Axis.<init>(Unknown Source)

In my application I have supplied the following:

System.setProperty ("awt.toolkit", "com.eteks.awt.PJAToolkit");
System.setProperty ("java.awt.graphicsenv",
"com.eteks.java2d.PJAGraphicsEnvironment");
System.setProperty ("java.awt.fonts",
"/usr/openwin/lib/X11/fonts/TrueType/");

Is this likely related to pja.jar not being found at run time?

[Subject changed by moderator]

jmennear

Member since : Jun 10, 2003
Messages : 5
 Jun 30, 2003 at 8:18 PM
The sys admin who is setting this up for me told me that he did the following:

-------------------------------------------------------------------------------

I simply updated setenv with the following:

JAVA_OPTS="$JAVA_OPTS -Djava2d.font.usePlatformFont=false -Xbootclasspath/a:$APPDIR/lib/pja.jar -Djava.awt.fonts=/opt/java/current/jre/lib/fonts -Dawt.toolkit=com.eteks.awt.PJAToolkit -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment"
export JAVA_OPTS

After that I checked the tomcat out file to verify that the classpaths were loading and the urls to make sure it actually worked.

-------------------------------------------------------------------------------

So, it seems that what he has added in should make my setProperties obsolete, perhaps I should remove them.

[Subject changed by moderator]

jmennear

Member since : Jun 10, 2003
Messages : 5
 Jun 30, 2003 at 9:39 PM
Here are the libs I have in WEB-INF/lib:

./pulse/webapps/ROOT/WEB-INF/lib/classes12.jar
./pulse/webapps/ROOT/WEB-INF/lib/jdbcpool-0.99.jar
./pulse/webapps/ROOT/WEB-INF/lib/jtds-0.5.1.jar
./pulse/webapps/ROOT/WEB-INF/lib/jfreechart-0.9.8.jar
./pulse/webapps/ROOT/WEB-INF/lib/jcommon-0.8.0.jar
./pulse/webapps/ROOT/WEB-INF/lib/gnujaxp.jar
./pulse/webapps/ROOT/WEB-INF/lib/pja.jar
./pulse/webapps/ROOT/WEB-INF/lib/pjatools.jar

And the demo code I'm using:

import java.io.OutputStream;
import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;

import org.jfree.chart.JFreeChart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.data.CategoryDataset;
import org.jfree.data.DatasetUtilities;
import org.jfree.data.DefaultCategoryDataset;

//import java.util.Properties;
//import java.io.PrintStream;

public class ServletDemo1 extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//System.setProperty ("awt.toolkit", "com.eteks.awt.PJAToolkit");
//System.setProperty ("java.awt.graphicsenv", "com.eteks.java2d.PJAGraphicsEnvironment"
);
//System.setProperty ("java.awt.fonts", "/usr/openwin/lib/X11/fonts/TrueType/");

OutputStream out = response.getOutputStream();
try {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(10.0, "S1", "C1");
dataset.addValue(4.0, "S1", "C2");
dataset.addValue(15.0, "S1", "C3");
dataset.addValue(14.0, "S1", "C4");
dataset.addValue(-5.0, "S2", "C1");
dataset.addValue(-7.0, "S2", "C2");
dataset.addValue(14.0, "S2", "C3");
dataset.addValue(-3.0, "S2", "C4");
JFreeChart chart =
ChartFactory.createVerticalBarChart("Bar Chart", "Category", "Value",
dataset, true, true, false);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, 400, 300);
} catch (Exception e) {
System.err.println(e.toString());
}

finally {
out.close();
}
}

}

I commented out the setProperties lines since the setenv file was updated to show define all the properties I needed.

It has been suggested that I use an ear file instead of a war file.

[Subject changed by moderator]

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jul 1, 2003 at 10:42 AM
> It has been suggested that I use an ear file instead of a war file.

I tried your servlet under Linux with a war file and it worked well...
I just put the 3 jar files jfreechart-0.9.8.jar, gnujaxp.jar, jcommon-0.8.0.jar in the WEB-INF/lib directory of the war file.

Maybe you should add the -Duser.home option to your java options (user.home should contain a lib directory with a font.properties file that uses only True Type font files like the one provided with PJA) :
JAVA_OPTS="$JAVA_OPTS -Djava2d.font.usePlatformFont=false -Xbootclasspath/a:$APPDIR/lib/pja.jar -Djava.awt.fonts=/opt/java/current/jre/lib/fonts -Dawt.toolkit=com.eteks.awt.PJAToolkit -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment -Duser.home=$APPDIR"

By the way take care of the result of a JAVA_OPTS="$JAVA_OPTS ... " line as it may accumulate different changes to JAVA_OPTS

Last thing. As you didn't mention which version of Tomcat you use, you should know that JAVA_OPTS is used by Tomcat 4.x and TOMCAT_OPTS is used by Tomcat 3.x
---
Manu (moderator/modérateur)

Mylacc

Member since : Jul 16, 2003
Messages : 6
 Aug 5, 2003 at 4:52 PM
It did not work for me in a war file either for my situation because I had to take the pja.jar out and have the Xbootclasspath point to the pja.jar that was taken out instead, it must not have been reading it inside of the war file.

ruzer

Location : Dublin, Ireland
Member since : Feb 21, 2004
Messages : 1
 Feb 21, 2004 at 2:57 AM
Can anyone tell me how to set JAVA_OPTS for tomcat running on solaris? There is no setenv batch file in the tomcat/bin folder. instead there is startup.sh, and catalina.sh. Do I need to modify these files?

Thanks
Ruzer
---
I wanna be your dog

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Feb 24, 2004 at 8:07 AM
You may set the JAVA_OPTS environment variable in catalina.sh directly if you want to...
---
Manu (moderator/modérateur)

nando

Location : Zurich
Member since : Nov 8, 2006
Messages : 1
 Nov 8, 2006 at 12:33 PM
Thanks Manu, for all your comments in this Thread.

I have a question, because in http://www.eteks.com/pja/en/forum/viewSubject.jsp?subjectId=518

you say :
"Before making any change to PJA Toolkit classes, I discovered that JDK 1.5 finally works correctly on headless systems installed with or without X11 libs.
Thus, I don't think I'll modify PJA Toolkit because I don't see why people should need it with JDK 1.5. "

Does it mean that with JDK 1.5 and headless, AWT works fine without _any_ X11 lib ?

Thanks.
---
real work, is tranforming dreams into realities.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Nov 8, 2006 at 1:39 PM
> Does it mean that with JDK 1.5 and headless, AWT works fine without _any_ X11 lib ?

Yes, from the few tests I did, AWT doesn't need any X11 lib anymore with Java 5.
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2014 eTeks - All rights reserved

PJAPJA documentation