Is there at least someone that could tell me where to find more information about the option "JAVA_OPTS=-Djava.awt.headless=true"? What exactly is its purpose? Thanks in advance.
Daniel On 5/6/05, Daniel Watrous <[EMAIL PROTECTED]> wrote: > Hello, > > I have a web application that uses java.awt.Font objects to render > images. The application will run in tomcat and that is where I have > done development. When I first tried to run the application on a > Linux box with Tomcat 5.0.25 I got the following error: > > java.lang.NoClassDefFoundError > at com.words2walls.customquote.CustomQuote.getQuoteFontName(Unknown > Source) > at com.words2walls.webapp.filters.SessionQuoteFilter.doFilter(Unknown > Source) > > Here is the code call that throws the error: > public String getQuoteFontName() { > return QuoteFontType.getInstance(this.quoteFontCode).toString(); > } > > And the class that is being called: > /* > * QuoteFontType.java > * > * Created on April 15, 2005, 9:41 AM > */ > > package com.words2walls.customquote; > > import java.awt.Font; > import java.awt.FontFormatException; > import java.util.*; > import java.io.*; > > import com.words2walls.customquote.exceptions.FontNotFoundException; > > /** > * Type safe enumeration of available fonts > * > * @author Daniel Watrous > */ > public class QuoteFontType { > > private static final String pathToWebapp = "C:\\Program > Files\\Apache Software Foundation\\Tomcat 5.0\\webapps\\words2walls"; > private static final String pathToPackage = > "\\WEB-INF\\classes\\com\\words2walls\\fonts\\"; > private String fontName; > private int fontCode; > private Font font; > private static org.apache.log4j.Category cat = > > org.apache.log4j.Category.getInstance(QuoteFontType.class.getName()); > > public static final QuoteFontType ADORABLE = new > QuoteFontType(1,"Adorable","adorable.ttf"); > private static final Map INSTANCES = new HashMap(); > > static { > cat.debug("Enter Static block to place fonts in INSTANCES Map"); > INSTANCES.put (ADORABLE.toInteger(), ADORABLE); > cat.debug("Exit Static block with INSTANCES.size() = " + > INSTANCES.size()); > } > > /** Creates a new instance of QuoteFontType */ > private QuoteFontType(int code, String fontName, String filename) { > // create a font from the font file > try { > File fontFile = new File (pathToWebapp+pathToPackage+filename); > FileInputStream fis = new FileInputStream(fontFile); > font = Font.createFont(Font.TRUETYPE_FONT, fis); > } catch (Exception e) { > throw new FontNotFoundException(e); > } > // set member variables > this.font = font; > this.fontCode = code; > this.fontName = fontName; > } > > public String toString() { > return fontName; > } > > public Integer toInteger() { > return new Integer(fontCode); > } > > public static QuoteFontType getInstance(int code) { > return (QuoteFontType) INSTANCES.get(new Integer(code)); > } > > public Font getFont() { > return font; > } > > } > > After some googling I found that if I set an environment variable > "JAVA_OPTS=-Djava.awt.headless=true" that this error would go away. > I'm not sure why this is the case, but it worked. > > I am now trying to test the application on a windows machine with > Tomcat 5.0.30 and I get the same error. I have set a Windows XP > environment variable the same as mentioned above. I have also added > the option to the Java tab of the Tomcat monitor under Java Options:. > > What is the cause of this error? Is there some way that I can make it > work on both Windows and Linux? Thanks in advance. > > Daniel > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]