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 Why my servlet can't find PJAGraphicsEnvironment ?

lcq210

Member since : May 23, 2003
Messages : 9
 May 23, 2003 at 3:10 AM
I'm really excited to find this website because I have problems to let my servlet draw graphics in web brower. I tried your product, my OS is linux,apache server,jdk 1.3,but I got the following errors when I tried to run PJAServletTest in my browser:
Default Toolkit or Font class couldn't be instantiated.
java.lang.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)
at PJAServletTest.test(PJAServletTest.java:75)
at PJAServletTest.doGetPJA(PJAServletTest.java:62)
at java.lang.reflect.Method.invoke(Native Method)
at com.eteks.awt.servlet.PJAServlet.HttpMethodInvoke(PJAServlet.java:793)
at com.eteks.awt.servlet.PJAServlet.doGet(PJAServlet.java:649)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:271)
at com.eteks.awt.servlet.PJAServlet.servicePJA(PJAServlet.java:785)
at java.lang.reflect.Method.invoke(Native Method)
at com.eteks.awt.servlet.PJAServlet.HttpMethodInvoke(PJAServlet.java:793)
at com.eteks.awt.servlet.PJAServlet.service(PJAServlet.java:775)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
at com.eteks.awt.servlet.PJAServlet.servicePJA(PJAServlet.java:637)
at java.lang.reflect.Method.invoke(Native Method)
at com.eteks.awt.servlet.PJAServlet.service(PJAServlet.java:606)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:484)

I really appreciate your help.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 May 24, 2003 at 12:11 AM
pja.jar must be added to bootclasspath (thanks to the java option -Xbootclasspath/a:pja.jar)
Please read the FAQ "What options do I have to add to java command line to use PJA with my servlet server on UNIX platform ?"

If you don't have access to the java command line you may change your servlet to use directly the com.eteks.awt.PJAImage class instead of java.awt.Image. Please write again if you need more help...

---
Manu (moderator/modérateur)

lcq210

Member since : May 23, 2003
Messages : 9
 May 24, 2003 at 9:10 AM
I've Read the FAQ 'What options do I have to add to java command line to use PJA with my servlet server on UNIX platform ?' I've done the first two step,but I don't know how to change the java command line, For example,where should I put '-Xbootclasspath/a:pja.jar'?Should I change some config file or what?

lcq210

Member since : May 23, 2003
Messages : 9
 May 24, 2003 at 9:15 AM
Thanks for your answer.
Actually I've added the pja.jar to the classpath.You see If I input 'set' command,I can find that my classpath set is :
CLASSPATH=./:/usr3/jdk1.3.1/jre/lib/rt.jar:/usr3/jsdk2.0/lib/jsdk.jar:/usr3/pja_2.4/lib/pjatools.jar:/usr3/pja_2.4/lib/pja.jar

And I've added the line 'wrapper.bin.parameter = -Xbootclasspath/a:/usr3/pja_2.4/lib/pja.jar' to the jserv.properties file.

I've run the PJADemo class ,and it works well.Is there any problem in the config file? Or What else should I do to get it work?

thanks.

lcq210

Member since : May 23, 2003
Messages : 9
 May 25, 2003 at 9:11 AM
I'm sorry to say that the problem is not resolved yet.When I ran the demo class PJADemo, it works well and created 3 gif files for me.But when I ran the ToolkitDemo,I got following errors:
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnv)
at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.Toolkit$2.run(Toolkit.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:503)
at ToolkitDemo.main(ToolkitDemo.java:106)
:(,I got confused.What shall I do?
Would you please explain it for me?

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 May 25, 2003 at 11:28 AM
I suspect you ran PJAToolkitDemo.sh and not PJAToolkitDemo1.2.sh, so Java use the default sun.awt.X11GraphicsEnvironment class as graphics environment instead of com.eteks.java2d.PJAGraphicsEnvironment class.
With a JDK version >= 1.2 you should use this command line :

java -Xbootclasspath/a:path/to/pja.jar -Dawt.toolkit=com.eteks.awt.PJAToolkit -Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment -Djava2d.font.usePlatformFont=false -Djava.awt.fonts=path/to/jdk/jre/lib/fonts -Duser.home=path/to/pja -classpath path/to/pjatools.jar ToolkitDemo

Replace the path/to... by the paths on your machine. The path/to/pja must contain the lib directory with a font.properties file.
---
Manu (moderator/modérateur)

lcq210

Member since : May 23, 2003
Messages : 9
 May 26, 2003 at 7:24 AM
Thank you so much.
Yes,It created 3 pictures,but not 4.
I still have problems.My servlet contain PJAGraphicsPolygonDrawer () works well in web browser,but if it create a PJAGraphicsTextDrawer object ,It can't find the .pjaf files.Actually the Albertus Medium.pjaf is in the same directory with the servlet.Then, I copied the Albertus Medium.pjaf to the /usr3/jdk1.3.1/jre/lib/fonts/ directroy, the servlet still can't find the .pjaf.

rahulkav

Member since : May 27, 2003
Messages : 3
 May 27, 2003 at 1:11 PM
hi,


I am getting the similar error:
Could not find class: com.eteks.java2d.PJAGraphicsEnvironment

The error is coming from a line where I am creating font
########################################################
f = new Font(strfont_name,Font.PLAIN,istrfont_size_to_int);
########################################################

I have modified the following System properties
awt.tookkit,java.awt.graphicsenv and java.awt.fonts.

I had added the PJA.jar(tried by extracting it as well) in the classpath. But didin't work.

Then from commandline I tried running the program with -Xbootclasspath/a: option. It works fine. But problem is I won't be able to run the program from command prompt. It will be called in by Application Server.

Then I tried one other way: I extracted the pja.jar file in the following folder
<jdk installation directory>/jre/classes and it seemed to work.

Is it possible to eliminate the error by just playing around with CLASSPATH???

Regards,

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 May 27, 2003 at 10:31 PM
> But problem is I won't be able to run the program from command prompt.
> It will be called in by Application Server.

What Application Server do you use ? It surely as an option that allows you to specify the -Xbootclasspath/a:path/to/pja.jar java option you need.

> Is it possible to eliminate the error by just playing around with CLASSPATH???

The com.eteks.awt.servlet.PJAServlet class was an attempt to avoid -Xbootclasspath option but I must confess that despite all my efforts I think it never worked as expected...
---
Manu (moderator/modérateur)

lcq210

Member since : May 23, 2003
Messages : 9
 May 28, 2003 at 2:13 PM
But where should I put the .pjaf file?

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 May 28, 2003 at 3:53 PM
> But where should I put the .pjaf file?

If your program or servlet never instantiate directly a PJA class (like new PJAImage (100, 100) ), you don't need any PJAF file with a JDK >= 1.2.

If you use JDK 1.1,
or if you make a direct use of a PJA class,
or if you set the com.eteks.awt.nojava2d System property to true, strings are drawn using fonts stored in PJAF files.
These files must be in the directory specified by the "java.awt.fonts" System property or in your current directory (specified by the "user.dir" System property).
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2014 eTeks - All rights reserved

PJAPJA documentation