Java.awt.Toolkit - Coldfusion - HELP

Greetings.
I am having a hard time with the following code:
<cfobject action="create" type="java" class="java.awt.Toolkit" name="fileObj">
<cfscript>
img = fileObj.getDefaultToolkit().getImage("images/products/39321.jpg");
width = img.getwidth();
height = img.getheight();
</cfscript>
<cfoutput>#height#</cfoutput>
I keep getting the following error:
java.lang.NoClassDefFoundError
My version of Java is 1.4.2. I'm running Redhat Linux 4.0. Coldfusion MX 6.1.
I know this isn't a Coldfusion forum, but I really need some help here.
I'm new to Java technologies, so any help will be greatly appreciated.

can ColdFusion load Java objects?
Presuming that it can, then ColdFusion probably needs some configuration to tell it the Java directory or where the class files are (JavaHome/jre/lib/rt.jar)

Similar Messages

  • Deprecation warning for getFontMetrics(java.awt.Font) in java.awt.Toolkit

    Hi all,
    When I use the following code
    JComponent c;
    FontMetrics metrics = getToolkit().getFontMetrics(c.getFont());
    I get this following warning during compilation:-
    warning: getFontMetrics(java.awt.Font) in java.awt.Toolkit has been deprecated
    JDK suggests to use getLineMetrics() of the Font class.
    But there's an issue with that: if I use getLineMetrics(), there is no API method that I can use to get the width of a string as opposed to FontMetrics which provides stringWidth(String str) method for that purpose. In fact all the methods in FontMetrics are not mapped into LineMetrics.
    Could anyone please help or provide me at least some pointers on how to tackle this issue so that I can get rid of the deprecated method along with the existing methods mapped to equivalent APIs? The bottomline is that I should be able to maintain the existing functinality of my application for those part of code that uses getToolkit().getFontMetrics().
    Thank you for your help in advance.
    -Sanjoy Das

    Use Graphics.getFontMetrics(font) instead.
    After creation your frame and calling frame.show();
    You can access it like that
    frame.show();
    frame.getGraphics().getFontMetrics(new Font("Arial",0,10));
    before showing graphics is null.
    Or just create a BufferedImage and ask it for graphics.
    BufferedImage img=new BufferedImage(...);
    img.getGraphics().getFontMetrics(font);
    regards
    Stas

  • Quality of Cursors created with java.awt.Toolkit(createCutsomCursor)

    Hi -
    I encountered a small problem while creating my own cursors for my Java application , I used the java.awt.Toolkit Objects createCustomCursor method to use a .GIF image as a cursor ... it worked but the quality of that cursor is horrible, the outline is rough ... I tried the same with a transparent PNG file afterwards unfortunately the same result , does anyone know why the quality is that bad or may this just be a problem of the choosen color pool ?
    Help would be very appreciated since I have no clue how to use .cur files ... seems like a non supported format , in case someone knows how to import those it would help a lot if you would drop some lines of code.
    I am currently using Java 2 SDK 1.4.0_01 , newest version.
    Thanks for you time and thanks in advance for possible answers
    -- Harald Scheckenbacher

    I noticed this problem too. It looks like the routine is generating cursors which are scaled to to the maximum size of the system. On my win XP system,
    Dimension dim = toolkit.getBestCursorSize(256, 256);
    int maxColors = toolkit.getMaximumCursorColors();
    return 32,32 and 256 respectively
    If I provide a 16x16, all the pixels have been pixel doubled. If I specify a 32x32 image, then the cursor looks perfect. This looks like a bug for the java folks. Not sure why someone would ever want a cursor image to be pixel scaled.
              

  • Substitute of java.awt.ToolKit.getDefaultToolKit.beep()

    Hello everybody. I am designing a Swing Application and there I am using java.awt.ToolKit.getDefaultToolKit.beep() method to generate sound in various operations. I want to know is it possible to generate own sound as a substitute of this method? I think it is possible. How can I do this? Thank you.

    Thank you for giving reply.
    As I wish to play .mp3 file I had downloaded an API from Javalobby . I tried it, here is my code :
    package player;
    import java.io.File;
    import java.io.IOException;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.SourceDataLine;
    * @author Tanmoy
    * @Super Scientific Calculator
    * @version 1.2010
    public class Player {
         private File audioFile;
         public Player(String path) {
              this.audioFile = new File(path);
         public void play() {
              AudioInputStream din = null;
              try {
                   AudioInputStream in = AudioSystem.getAudioInputStream(audioFile);
                   AudioFormat baseFormat = in.getFormat();
                   AudioFormat decodedFormat = new AudioFormat(
                        AudioFormat.Encoding.PCM_SIGNED,
                        baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
                        baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
                        false);
                   din = AudioSystem.getAudioInputStream(decodedFormat, in);
                   DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
                   SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
                   if (line != null) {
                        line.open(decodedFormat);
                        byte[] data = new byte[4096];
                        line.start();
                        int nBytesRead;
                        while ((nBytesRead = din.read(data, 0, data.length)) != -1) {
                             line.write(data, 0, nBytesRead);
                        line.drain();
                        line.stop();
                        line.close();
                        din.close();
              } catch (Exception e) {
              } finally {
                   if (din != null) {
                        try {
                             din.close();
                        } catch (IOException e) {
    }And the calling, piece of code is :
    try {
                                  Parser parser = new Parser(parsingString, displayPanel.getCurrentBase(),
                                       displayPanel.getCurrentBase(), displayPanel.getTrigoMode(),
                                       displayPanel.getScale());
                                  String output = parser.solve();
                                  displayPanel.outputTextField.setText(output);
                                  displayPanel.outputTextField.setCaretPosition(displayPanel.outputTextField.getText().length());
                                  displayPanel.charLabel.setText((Integer.toString(output.length())));
                                  if (message == null) {
                                       message = "No Exception";
                             } catch (InvalidSyntaxException invalidSyntaxException) {
                                  message = invalidSyntaxException.getMessage();
                                  JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
                                  new Player("/resources/what_the_hell.mp3").play();
                                  displayPanel.outputTextField.setText("0");
                                  displayPanel.charLabel.setText("0");
                             }But I can not able to here the sound.
    What to do now?
    Thank you.

  • Java Wireless Toolkit Setup Help Needed

    I am interseted in mobile application development, and I have recently tried to set up the Java Wireless toolkit 2.0 on my laptop.
    I have spent gours trying to get it to work correctly - still nothing!!
    When it's all installed, I have opened up the sample projects -- e.g. Games.
    When I hit 'Build' I am given the following error:
    Project "games" loaded
    Project settings saved
    Building "games"
    C:\WTK20\apps\games\src\example\pushpuzzle\PushPuzzle.java:145: cannot access java.lang.StringBuilder
    file java\lang\StringBuilder.class not found
    alert.setString("Could not load level " +
    ^
    com.sun.kvem.ktools.ExecutionException
    Build failed
    Can someone please tell me what to do?!?
    Is it to do with setting the classpath?? How do I do that??
    What other Java tools do I need to have prior to installing the Wireless toolkit?? JVM?? Where do I get this? How do I install it correctly and set paths correctly??
    Any help would be HUGELY appreciated as I have downloaded so much stuff at this stage I have compleely confused myself!!

    Hey.
    Right, last night I downloaded the latest version of JDK - version 1.5.
    I installed it successfully.
    So in the folder C:\ Java there are two folders: Jdk-1.5_etc and JRE-1.5_etc.
    Next I downloaded and installed the latest version of the wireless toolkit.
    It saw that I had the JDK installed at th correct folder, and it installed at C:\WTK20 - said it installed correctly.
    So, next I select create project - call it hello world.
    Then I place the following code in the src folder of the helloWorld folder:
    * Copyright 2000-2001 by Sun Microsystems, Inc.,
    * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
    * All rights reserved.
    package examples.helloworld;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class HelloWorld extends MIDlet implements CommandListener {
    private Command exitCommand;
    private TextBox tb;
    public HelloWorld() {
    exitCommand = new Command("Exit", Command.EXIT, 1);
    tb = new TextBox("Hello MIDlet", "Hello, World!", 15, 0);
    tb.addCommand(exitCommand);
    tb.setCommandListener(this);
    protected void startApp() {
    Display.getDisplay(this).setCurrent(tb);
    protected void pauseApp() {}
    protected void destroyApp(boolean u) {}
    public void commandAction(Command c, Displayable d) {
    if (c == exitCommand) {
    destroyApp(false);
    notifyDestroyed();
    I hit build and it builds correctly - no errors - YAY!!.
    I hit run, the phone emulator pops up. I hit launch and:
    An error pops up on the screen of the phone.
    The error below appears in the Wireless toolkit window:
    Project "HelloWorld" loaded
    Project settings saved
    Building "HelloWorld"
    Build complete
    Running with storage root DefaultColorPhone
    Unable to create MIDlet HelloWorld
    java.lang.ClassNotFoundException: HelloWorld
         at com.sun.midp.midlet.MIDletState.createMIDlet(+14)
         at com.sun.midp
    I'm using version 1.5 of JDK - what have I not done - why won't it run.
    I keep getting Java.lang errors!!!!
    AAAGGGHHHHH!!!!!!!!!!!!!!!

  • Java.awt.Toolkit.getScreenSize()

    Hello again world.
    I'm a little confused here. I have these two lines in a program:
    Toolkit tKit = Toolkit.getDefaultToolkit();
    Dimension size = tKit.getScreenSize();
    Reading the API, I notice that "getScreenSize()" is declared abstract.
    I was under the impression that abstract methods need to be overridden and have no actual code.
    if (that's correct)
       return "What's up with that second line?";
    else
       return "What's the deal with abstract methods?";Thank you one and all.
    Ciao for now.

    I don't understand.
    How does that tell me the "getScreenSize()" is
    defined?
    Do I just trust that the abstract method has been
    overridden in that implementation?Abstract methods can only exist in abstract classes and interfaces. A non-abstract class, commonly referred to as a concrete classes, cannot have abstract methods. Only concrete classes can be instanciated, therefore, if you have an instance of some abstract class, then you know that it is an instance of some concrete subclass of the abstract class. This tells you that all abstract methods have been implemented. So, just the simple fact that you actually have an instance of the object tell you that all the abstract methods are implemented.
    Where are these classes anyhow?Doesn't matter. Like someone said earlier, that is the beauty of polymorphism and inheritance.

  • Eexception in java.awt.AWTError

    Hi all,
    I am starting with java in my Ubuntu box, and am faced with a problem.
    Consider a simple program
    import javax.swing.*;
    import java.awt.*;
    class helloSwing{
         public static void main(String[] args)
              JFrame myWindow;
              myWindow = new JFrame();
              myWindow.setSize(300,200);
              myWindow.setTitle("My First Swing Application");
              myWindow.setVisible(true);
              System.exit(0);
    }when I run this program
    neo@tathagata:~/Java Progs$ java helloSwingThis is the error I am getting
    Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
       at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0)
       at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JComponent.revalidate() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JComponent.setOpaque(boolean) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JPanel.JPanel() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.createGlassPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.getGlassPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.JRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.createRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.getRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.frameInit() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.JFrame() (/usr/lib/libgcj.so.6.0.0)
       at helloSwing.main(java.lang.String[]) (Unknown Source)
       at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
       at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
       at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0)
       ...17 moreIt appears whenever I'm importing some packages it is creating a problem.
    With whatever little knowledge of Java I have, I suspect I have messed up in the enviornment variables somewhere.
    So here are my
    PATH=/usr/local/qt-x11-opensource-src-4.1.0/bin:/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/games:/home/neo/jdk1.3.1_17/bin/:/usr/sbin:/usr/java/jdk1.3.1_17/bin
    JAVA_HOME=/usr/java/jdk1.3.1_17Can anybody suggest me an easy link where classpath is explained?
    I'm am helpless, coz if this is not getting fixed I need to go back to Windoz ..
    leaving Ubuntu, which would be really painful.
    Please help. Thanks in Advance.

    Cool, I glad it's working. And thanks for the kind words (although
    your link sent me some sort of Introduction page, I eventually found
    "Tatha's blog").
    Now all I have to do is get my setup correct. Also 1.5, also Ubuntu.
    I screwed something up when I installed Netbeans, and couldn't
    understand how the Debian people have set things up. I just type the
    executable's path at the command line (easy with *nix) or let Eclipse
    just do the right thing.
    Cheers,
    Peter

  • Java game app - need help on creating more adversaries

    HI all, this app is a simple game where the objective is to avoid incoming balls (adversaries) however at present I can only figure out how to get one ball on screen at a time. What I'd really like is, when a player hits 100 points, a second ball is spawned (thus making the game harder) I would like the same to occur at 200 points (3 balls), 400 pts (4 balls) and so forth. I am sure there is a simple way of doing this. what I have tried is creatin new instances of Ball, but to no avail.any help would be greatly appreciated.
    cheers
    /* A game that is Saucer-like
    * Phillip Wells
    //to do - make more balls when 100 points met
    import java.awt.*;
    import java.awt.Toolkit.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.util.concurrent.*;
    public class Saucer extends JFrame {
        public static final int WIDTH = 400;
        public static final int HEIGHT = 400;
        Image img;
        private PaintSurface canvas;
        public void init() {
            this.setSize(WIDTH, HEIGHT);
            this.setTitle("Saucer");
            canvas = new PaintSurface();
           img = Toolkit.getDefaultToolkit().getImage("space.gif");
            this.getContentPane().add(canvas, BorderLayout.CENTER);
            ScheduledThreadPoolExecutor executor =
                    new ScheduledThreadPoolExecutor(3);
            executor.scheduleAtFixedRate(new AnimationThread(this),
                    0L, 20L, TimeUnit.MILLISECONDS);
            setVisible(true);
        class AnimationThread implements Runnable {
            JFrame c;
            public AnimationThread(JFrame c) {
                this.c = c;
            public void run() {
                c.repaint();
        class PaintSurface extends JComponent {
            int saucer_x = 0; // start position of saucer
            int saucer_y = 180;
            int score = 0;
            Ball Ball;
            Color[] color = {Color.RED, Color.ORANGE,
            Color.MAGENTA, Color.ORANGE,
            Color.CYAN, Color.BLUE};
            int colorIndex;
            public PaintSurface() {
                addMouseMotionListener(new MouseMotionAdapter() {
                    public void mouseMoved(MouseEvent e) {
                        saucer_x = e.getX() -30;
                        saucer_y = e.getY() -0;
                Ball = new Ball(30);
            public void paint(Graphics g) {
                Graphics2D g2 = (Graphics2D)g;
                g2.setRenderingHint(
                        RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
                        Shape saucer = new Ellipse2D.Float(
                        saucer_x, saucer_y, 60, 10); // saucer dimensions
                g2.drawImage(img, 0, 0, this);
                g2.setColor(color[colorIndex % 6]);
                if (Ball.intersects(saucer_x, saucer_y, 60, 10)
                && Ball.y_speed > 0) {
                    Ball = new Ball(20);
                    score -= 100;
                    colorIndex = 0;
                else if (Ball.getY() + Ball.getHeight() >= Saucer.HEIGHT)
                    Ball = new Ball(20);
                    score += 10;
                    colorIndex = 0;
                Ball.move();
                g2.fill(Ball);
                g2.setColor(Color.GREEN);
                g2.fill(saucer);
                g2.drawString("Score: " + score, 250, 20);      
                if (score == 20)
        class Ball extends Ellipse2D.Float {
            public int x_speed, y_speed;
            private int d;
            private int width = Saucer.WIDTH;
            private int height = Saucer.HEIGHT;
            public Ball(int diameter) {
                super((int)(Math.random() * (Saucer.WIDTH - 20) + 1),
                        0, diameter, diameter);
                this.d = diameter;
                this.x_speed = (int)(Math.random() * 5 + 5);
                this.y_speed = (int)(Math.random() * 5 + 5);
            public void move() {
                if (super.x < 0 || super.x > width - d)
                    x_speed = -x_speed;
                if (super.y < 0 || super.y > height - d)
                    y_speed = -y_speed;
                super.x += x_speed;
                super.y += y_speed;
    }

    On an off note, there are some things you can do here to make multiple balls much easier to create, track, and manage. One thing is that your Ball class should have a record of all properties that are in anyway related to a Ball object.
    I notice that you handle Ball color within your paint method. Your Ball class should have a Color field so every instance of Ball is aware of its color, and then your paint method can grab the necessary color from the object itself that it is painting. You wont need to keep a color index and color collection.
    Secondly, to track multiple balls you will need a collection object that holds multiple Ball objects. Everything in your paint method right now is looking at one instance of Ball because there is only one reference of Ball. Instead of doing it this way you can keep a number of Ball objects in an ArrayList lets say, and then create a for loop that iterates through element of the List, and performs operations on that ball, like grabbing its color, filling the shape, calling the Ball's move method.

  • Java.awt.Dialog in Java 1.6 has a memory leak

    When a modal Dialog opens a modal sub-dialog, the Dialog stays in memory after both the sub-dialog and the Dialog itself is disposed.
    The field that contains the leaked object is Dialog.modalDialogs (static). The methods which causes the leak are Dialog.modalHide and Dialog.modalShow.
    Whenever a modal Dialog is opened, Dialog.modalShow is called, and adds itself to Dialog.modalDialogs.
    When it closes, Dialog.modalHide is called and removes one copy of itself from Dialog.modalDialogs. Then Dialog.modalShow is called on all previously blocked modal dialogs. When the sub-dialog is opened and closed, Dialog.modalDialogs contains two references to the main Dialog, and only one of them is removed when Dialog.modalHide for that Dialog is called.
    To detect the leak, just put a break point in Dialog.modalHide, after modalDialogs.remove(this);. When opening a Dialog and closing it without opening a sub-dialog, the Dialog.modalDialogs field should be empty. When a sub-dialog was opened and closed before the main Dialog is closed, the Dialog.modalDialogs field contains a reference to the disposed main Dialog.
    This leak does not exist in 1.5.0_10 (no Dialog.modalDialogs field). I have searched the bug database, but I have not found this bug there. Could anyone confirm this?
    A simple code to reproduce the leak:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    public class Test {
       public static void main(String[] args) {
          final JFrame frame = new JFrame() {
             protected void processWindowEvent(WindowEvent e) {
                super.processWindowEvent(e);
                if (e.getID() == WindowEvent.WINDOW_CLOSING) {
                   System.exit(0);
          JButton button = new JButton("Dialog");
          button.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent aE) {
                JButton subButton = new JButton("SubDialog");
                subButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent aE) {
                      JOptionPane.showMessageDialog(frame, "SubDialog");
                JOptionPane.showMessageDialog(frame, subButton);
          frame.getContentPane().add(button);
          frame.pack();
          // Center the window
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          Dimension frameSize = frame.getSize();
          if (frameSize.height > screenSize.height) {
             frameSize.height = screenSize.height;
          if (frameSize.width > screenSize.width) {
             frameSize.width = screenSize.width;
          frame.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2);
          frame.setVisible(true);
    }

    Sorry, I just found the bug in the bugdatabase (with google of course,):
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929]

  • Can I draw *.bmp, *.png in java.awt.canvas ?

    In paint method of my program, I get image from Toolkit like this:
    public class CanCanvas extends Canvas{
    //In loadImage method
    Toolkit.getDefaultToolkit().getImage(
                        getClass().getClassLoader().getResource(
                                  resource.getString("bg.jpg")));
    //.... In paint method
    if (image != null && image.size() > 0) {
                   for (int j = 0; j < image.size(); j++) {
                        Image image1 = (Image) image.elementAt(j);
                        Rectangle rectangle = (Rectangle) imgLocation.elementAt(j);
                        g.drawImage(image1, rectangle.x, offset + rectangle.y,
                                  rectangle.width, rectangle.height, null);
                        i = i <= rectangle.y + rectangle.height + 7 ? rectangle.y
                                  + rectangle.height + 7 : i;But there is something very strange, if my image is *.jpg or *.gif, it runs ok, otherwise -*.bmp, *.png-, it can't draw the image.
    Would anyone tell me why ? Is the reason java.awt.canvas ?
    Thanks in advance ^ ^

    If you'd bother to read the documentation of the methods you're using, you'd know:
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Toolkit.html#getImage(java.lang.String)
    Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG.

  • Problems with awt.Toolkit on Tomcat

    Hello! I'm trying to get the Default Toolkit (java.awt.Toolkit.getDefaultToolkit() ) to determine the scrren size of the client, and Tomcat keeps throwing an Exception - now it's the website's Tomcat and the one on my localhost - there it worked.. Is there another way to determine the client's screen size in JSP (not JavaScript!)?? Thanx!

    first, the previous poster was right - learn how these protocols are interacting before you try something like you want to do - and they're right, you can't use the AWT toolkit to find out ANYTHING about the client.
    HTTP is stateless. so it's like this:
    browser request -> your code on server, jsp completely exeutes, generates html -> html PLAIN old html goes to the browser. in that order. no exceptions. ergo, all your code has executed once the browser starts getting data (buffers on the server not withstanding).
    As to why you're getting the exception, the server you are trying to run it on is most likely running in a mode called "headless", that is, there is no windowing api available to the JVM, so any awt calls will fail anyway. It works on your box because you are probably running a full windowing os, such as windows or Linux with gnome or kde. it just happens to return the correct screen size because that's the screen size of your screen, not the screen of the browser that it's outputting to. (try running your code locally and making your browser window small, you'll be dismayed that the rendered HTML is not the "right" size - because the screen size call was based on your resolution, NOT the size of the requesting browser window.
    if the last 2 sentences don't make sense, re-read them until they do.
    best of luck, sorry you're learing these frustrating lessons this way.

  • Java.awt availability in CDC Toolkit ?

    Hi guys and girls,
    I've just tried out the Sun Java Toolkit for CDC 1.0 .. I tried making a simple app which uses awt components, such as Frame, Label, Button .. but the Label and Button just wont compile. I always thought that CDC has all the lib for the j2se's java.awt.
    Quoted from CDC FAQ :
    CDC currently supports three profiles. Foundation Profile provides basic application support APIs without any additional support for GUIs. Personal Basis Profile includes all of the APIs contained in Foundation Profile and adds support for lightweight AWT GUI components and the xlet application model. Personal Profile includes all of the APIs contained in Personal Basis Profile and adds support for full AWT compatibility and the applet application model.
    Do i miss something .. ? Please help pointing out for me ..
    I understand that there's swing from the AGui. So i tried making a new project with a simple class containing a simple JFrame, containing a JPanel which contains a button, which can be clicked to trigger a message type JOptionPane. But when the JOptionPane appears, it fills up the entire screen, i dont quite understand what is wrong.
    Here's the code :
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class HelloWorld {
          * @param args
         public static void main(String[] args) {
              final JFrame frame = new JFrame("Ahiak");
              final JPanel panel = new JPanel(new FlowLayout());
              JButton but = new JButton("Click Me !");
              panel.add(but);
              frame.getContentPane().add(panel);
              but.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        JOptionPane.showMessageDialog(panel, "hahah !");
              frame.setVisible(true);
    }Please show some compassion and click the reply button, lol -_-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I don't know about swing, but you can try using AWT and compile it with J2SE (set compliance to 1.4). The jar file should work on your mobile device with Personal Profile.

  • Using palm os emulator through java wireless toolkit!!.....pls help

    I have palm os emulator 3.5 installed.I am trying to integrate it wid d java wireless toolkit 2.2,in addition to d default devices provided by d toolkit.But i hav failed to integrate pose in jwtk.
    i am running midp2.0 and cldc1.1.
    Also i have downloaded d rom files required by d emulator.
    Pls anyone help me!!
    How can i use palm os emulator through java wireless toolkit?
    thanking you
    shivam sahai

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

  • "Cannot load AWT toolkit" - help!

    I get the "Cannot load AWT toolkit" error when I try to include awt functionality. Any suggestions?
    JAVA_HOME, CLASSPATH and PATH are set...what next?
    Thanks!
    Regards,
    -Rob

    The application compiled fine....
    "javac xxxx.java"
    - no errors
    It happens when I try to run it from the command line.
    "java xxxx"
    - Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
    Thanks!
    -Rob

  • Need help with Socket prog using Java wireless toolkit

    Hi, I am not able to communicate between client (Palm emulator) and server (Java on computer) using Java Wireless toolkit.
    Can anyone please tell me a site that shows an example. I have seen a bunch of examples but they all run by importing com.sun.kjava which seems to have vanished into thin air. So I cannot run them. Someone please show me some lines of code that will send just one character from client Palm emulator to server. thanks.
    Syed

    hi,
    I hope that you already have the J2ME Toolkit and that your emulator works okay. In the toolkit you get several examples to show you how to program a MIDlet. One has to do with a HTTP client server connection. Also in the API documentation for the J2ME there is a Connector class that you used to set up this communication and in the description of this class it pretty thoroughly explains how to set up an HTTP protocol client.
    However, if you want to do some other kind of networking then you are pretty much out of luck, as the TCPIP socket protocol has not been fully implemented and is optional to the J2ME specifications, only the HTTP protocol is certain to be available. This means that mobile phone companies can add other networking functionality to their phone's java virtual machine if they feel like it. This is a bummer I know.
    I hope this helps.
    Cheers,
    Mark

Maybe you are looking for

  • ITunes will not recognize my 4th generation Shuffle

    I bought a new shuffle last week and now when I plug it in to my computer (a macbook) iTunes won't recognize it and there's an orange flashing light. The iPod does show up on my desktop though. Any ideas on what's causing the problem??

  • Function module or logic for Production order Classification Controlling

    Hi All, I am going to CO03 transaction and display Production Order . ThenI am following path: Header-->Classification Controlling. Now i can see the General Characterstic descritpton and Value. Can some one give me the FM or logic, to read the Contr

  • Usr/local/bin...or where?

    hey guys, I just made a package of sylpheed claws 2.00.  Everything went ok, but the binary was placed in /usr/local/bin.  For reasons I don't quite understand, this is not an arch-like place to be.  So where should I put it, and how should I modify

  • Lacie Rugged Harddrive on OSX 10.4

    Is it possible to mount a lacie rugged drive on a powerbook g4 running OSX 10.4? It's not showing up in disk utility, but everything mounts fine on my imac running 10.7

  • ODBC database access

    Can we access a 'remote' ODBC compliant database through a JSP page being served by Weblogic? I know that the bridge cannot be used as it is not threadsafe but has that changed or is there any other way? Also, can we link in libraries within Weblogic