dcsimg
Toolkit problem in linux
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Thomas_Mathew
Posted On:   Friday, May 18, 2001 03:30 AM

Using Redhat Linux6.2,Apache , GNUJSP .. i'm trying to get the height ,width of the image uploaded to the server , <%@ page import = "java.awt.*"%> <% Image im ; Frame frm = new Frame(); out.println("3"); Toolkit tol = Toolkit.getDefaultToolkit(); out.println("2"); im = tol.getImage("dirName"+li); MediaTracker tracker = new MediaTracker(frm); out.println("1"); tracker.addImage(im,0); try{ tracker.waitForID(0); } catch(Exception e){out.println(e);} wg = im.getWidth(null); hg = im.getHeight(null); %> but when Toolkit is intialized the screen goes blank ..p   More>>

Using Redhat Linux6.2,Apache , GNUJSP .. i'm trying to get the height ,width of the image uploaded to the server ,
<%@ page import = "java.awt.*"%>
<%
Image im ;
Frame frm = new Frame();
out.println("3");
Toolkit tol = Toolkit.getDefaultToolkit();
out.println("2");
im = tol.getImage("dirName"+li);
MediaTracker tracker = new MediaTracker(frm);
out.println("1");
tracker.addImage(im,0);
try{
tracker.waitForID(0);
}
catch(Exception e){out.println(e);}
wg = im.getWidth(null);
hg = im.getHeight(null);
%>
but when Toolkit is intialized the screen goes blank ..pls do help to resolve this problem on Linux .
thanks

   <<Less

Re: Toolkit problem in linux

Posted By:   Nathan_Meyers  
Posted On:   Friday, May 18, 2001 12:00 PM

See also
this
FAQ entry
for further discussion.

Re: Toolkit problem in linux

Posted By:   Christopher_Schultz  
Posted On:   Friday, May 18, 2001 08:22 AM

If you use basically anything associated with Java's AWT on UNIX, you must have an X server running. Most Linux users have an X server running, but that's not always enough.



The best thing to do is use something like xvfb which is the X-windows virtual frame buffer. That'll allow you to start a X server without a display (with no monitor). See, Java doesn't care about displaying anything. It just wants to use some services that X-windows provides. That's why you need the server.



Start up the server using a display number like "25" and then do:



$ export DISPLAY=localhost:25



...before you start the server. That will make GNUJSP use your new X server for all it's rendering needs.



If you don't want to do all that, an alternative is to use a 3rd party package that can read/write graphics without using AWT, OR get the specs for GIF and JPEG formats and read the file headers yourself to determine the height and width. This will probably be faster than using AWT, anyway, and having a faster Servlet is always nice {;-)



Good luck,

-chris
About | Sitemap | Contact