Problem Loading an Image with javax Swing from a JApplet

First of all, i use JCreator as java creater and have the newest version of java sdk version.
Now i need to load an image from the harddrive on which the JApplet is located. I need to do this from inside the JApplet. I have put my pictures in a map 'images' which is located in the same directory as the classes + htm file. It works from inside JCreator, but as soon as i open the normal htm it just WON'T load that image (grmbl).
Here is my code for loading the image:
public BufferedImage loadImage (String filename, int transparency)
     Image image;
     if (app)
          image = Toolkit.getDefaultToolkit().getImage(("./images/"+filename));
     else
          String location = "";
          location = "./images/"+filename;
          image = Toolkit.getDefaultToolkit().getImage(location);
     MediaTracker mediaTracker = new MediaTracker(new Container());
     mediaTracker.addImage(image, 0);
     try
          mediaTracker.waitForID(0);
     catch (Exception e)
Could anybody help me out here??
I tried a url already using getCodeBase() or getDocumentBase() but that gives an error because it cannot find those if using a JApplet.

Why don't you use javax.swing.ImageIcon? If you already have a flag telling if it's an application or applet, use the getDocumentBase() to base the URL in the applet part only.

Similar Messages

  • Problem opening an Image with Swing

    I write an action listener for the choose class but when I try to open an image into my Jpanel I have the following error: (The problem seems to be the Null pointer because the image was not read or.....)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Genim$choose.actionPerformed(Genim.java:219)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    THE CODE IS :
    public class choose implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    int option = chooser.showOpenDialog(Genim.this);
    double [][] F = new double[90000][5];
    int i=0;
    if (option == JFileChooser.APPROVE_OPTION) {
    try{
    BufferedReader in = new BufferedReader(new FileReader(chooser.getSelectedFile())); //file contenente i
    String getname= chooser.getSelectedFile().getName();
    while (true)
    String s = in.readLine();
    if(s==null){
    break;
    StringTokenizer t = new StringTokenizer(s,"\t");
    double uno = Double.parseDouble(t.nextToken());
    double due = Double.parseDouble(t.nextToken());
    double tre = Double.parseDouble(t.nextToken());
    double quattro = Double.parseDouble(t.nextToken());
    double cinque = Double.parseDouble(t.nextToken());
    F[0]=uno;
    F[i][1]=due;
    F[i][2]=tre;
    F[i][3]=quattro;
    F[i][4]=cinque;
    if(i<90000) i=i+1;
    if(i==89999) accButton.setText("FIRST YEAR ACQUIRED");
    in.close();
    input8=F;
    input10=getname.substring(0, 4) ;
    catch (Exception e)
    accButton.setText("File input error");
    Image image = null;
    try {
    // Read from a file
    File file = new File(input10+".jpeg");
    image = ImageIO.read(file);
    } catch (IOException e) {}
    image = image.getScaledInstance(200,200,image.SCALE_FAST);
    JLabel label = new JLabel(new ImageIcon(image));
    buttonPanel.add(label, BorderLayout.EAST); ---->ERROR !!!!
    contentPane.add(label);-------------------------------->ERROR!!!!!
    Message was edited by:
    princo

    I will try to be clear:
    I want to open a file with the class choose and I want also in the same class to load an image with the command ImageIo.read()., to resize it and then to add this image as an icon into the Jpanel.
    I don't know why I receive the error in the final part ( LINE 223 and 224 are shown below) of the class choose:
    buttonPanel.add(label, BorderLayout.EAST); ---->ERROR !!!!
    contentPane.add(label);-------------------------------->ERROR!!!!!
    maybe the image is not fully loaded..
    I think that davedes has understood my problem but the modify that he proposed doesn't work---> The same error.
    The class choose is :
    public class choose implements ActionListener {
        public void actionPerformed(ActionEvent ae) {
        int option = chooser.showOpenDialog(Genim.this);
         double [][] F = new double[90000][5];
         int i=0;
          if (option == JFileChooser.APPROVE_OPTION) {
            try{
              BufferedReader in = new BufferedReader(new FileReader(chooser.getSelectedFile())); //file contenente i
              String getname= chooser.getSelectedFile().getName();       
              while (true)
                String s = in.readLine();
               if(s==null){
                 break;
               StringTokenizer t = new StringTokenizer(s,"\t");
               double uno = Double.parseDouble(t.nextToken());
               double due = Double.parseDouble(t.nextToken());
               double tre = Double.parseDouble(t.nextToken());
               double quattro = Double.parseDouble(t.nextToken());
               double cinque = Double.parseDouble(t.nextToken());
               F[0]=uno;
    F[i][1]=due;
    F[i][2]=tre;
    F[i][3]=quattro;
    F[i][4]=cinque;
    if(i<90000) i=i+1;
    if(i==89999) accButton.setText("FIRST YEAR ACQUIRED");
    in.close();
    input8=F;
    input10=getname.substring(0, 4) ;
    catch (Exception e)
    accButton.setText("File input error");
    Image image = null;
    try {
    // Read from a file
    File file = new File("2001.jpeg");
    image = ImageIO.read(file);
    } catch (IOException e)
    {//e.printStackTrace(System.out);
    //System.err.println(e.getMessage());
    System.exit(1);
    image = image.getScaledInstance(200,200,image.SCALE_FAST);
    JLabel label = new JLabel(new ImageIcon(image));
    buttonPanel.add(label, BorderLayout.EAST);
    contentPane.add(label);
    The error is:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at Genim$choose.actionPerformed(Genim.java:223)
            at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
            at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
            at java.awt.Component.processMouseEvent(Unknown Source)
            at javax.swing.JComponent.processMouseEvent(Unknown Source)
            at java.awt.Component.processEvent(Unknown Source)
            at java.awt.Container.processEvent(Unknown Source)
            at java.awt.Component.dispatchEventImpl(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Window.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.run(Unknown Source)THANK YOU VERY MUCH FOR YOUR HELP
    Message was edited by:
    princo

  • Problem accessing R/3 with SSO ticket from the EP6.0

    Hi all,
    I have seen this thread: Problem accessing R/3 with SSO ticket from the EP6.0
    I know that it is possible to read SSO ticket from the Cookie in WebDynpro application.
    Now we are at the first step, we don't know how to read SSO ticket from the Cookie in WebDynpro application with java code.
    So anyone can help us?

    Hi,
    This has been discussed in a previous forum.Check this link.A code snippet is also there to read a cookie in webdynpro with this question
    How to implement SSO between Portal, Webdypro and ABAP system?
    I am not able to send the link exactly.
    Regards,
    Sowjanya.
    Message was edited by: Sowjanya Chintala

  • Good day I need the solution to the problem presented my iphone with ios upgrade from 7 to access any app, I get a message that says "log on to itunes to receive notifications"

    Good day I need the solution to the problem presented my iphone with ios upgrade from 7 to access any app, I get a message that says "log on to itunes to receive notifications"

    After the iOS 7.0.2 update words with friends is not working for me either. When I attempt to open the app it just closes itself after a few seconds of being open. This happens every time I attempt to open it.

  • Problem loading & displaying images from URL

    hi,
    I can't manage to display an image into a component from a url... here is what my code looks like :
    public class ImageComponent extends JComponent{
        private ImageIcon imageIcon;
        public void paint(Graphics g){
            if(imageIcon!=null){
                imageIcon.paintIcon(this, g, posX, posY);
        private void loadsImage(String imageURL){
            imageIcon = new javax.swing.ImageIcon(imageURL);
            invalidate();
    }when I call loadImage with a proper url, the image doesn't seem to be loaded...
    it might be that the image is big and long to come (also my connection isn't that fast)... but forcing the repaint of the component (by hiding/showin the component's window) after a good while doesn't do much...
    can anybody tell me where I'm doing wrong...
    cheers,
    DrLeinster

    hi,
    looks like PaintComponent() instead of paint did the job.
    thanks a million..
    for those interested in loading images, I find ImageIcon very limited and at the end I found a better solution :
    public class ImageComponent extends JComponent implements ImageObserver{
        private Image image;
        public void loadImage(URL imageURL){           
                image = Toolkit.getDefaultToolkit().getImage(imageURL);
                prepareImage(image,getWidth(),getHeight(), this);
        public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height){
            System.out.print("."); // loading progress...
        public void paintComponent(Graphics g){
            if(image!=null){
                 g.drawImage(image,0,0,null);
    }it is far nicer as it displays dots while loading... up to you to attach progress bars or favorit loading guizmo...
    DrLeinster.

  • Loading an image into an Applet from a JAR file

    Hello everyone, hopefully a simple question for someone to help me with!
    Im trying to load some images into an applet, currently it uses the JApplet.getImage(url) method just before registering with a media tracker, which works but for the sake of efficiency I would prefer the images all to be contained in the jar file as oppossed to being loaded individually from the server.
    Say I have a class in a package eg, 'com.mydomain.myapplet.class.bin' and an images contained in the file structure 'com.mydomain.myapplet.images.img.gif' how do I load it (and waiting for it to be loaded before preceeding?
    I've seen lots of info of the web for this but much of it is very old (pre 2000) and im sure things have changed a little since then.
    Thanks for any help!

    I don't touch applets, so I can't help you there, but here's some Friday Fun: tracking image loading.
    import java.awt.*;
    import java.awt.image.*;
    import java.beans.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.imageio.event.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class ImageLoader extends SwingWorker<BufferedImage, Void> {
        private URL url;
        private JLabel target;
        private IIOReadProgressAdapter listener = new IIOReadProgressAdapter() {
            @Override public void imageProgress(ImageReader source, float percentageDone) {
                setProgress((int)percentageDone);
            @Override public void imageComplete(ImageReader source) {
                setProgress(100);
        public ImageLoader(URL url, JLabel target) {
            this.url = url;
            this.target = target;
        @Override protected BufferedImage doInBackground() throws IOException {
            ImageInputStream input = ImageIO.createImageInputStream(url.openStream());
            try {
                ImageReader reader = ImageIO.getImageReaders(input).next();
                reader.addIIOReadProgressListener(listener);
                reader.setInput(input);
                return reader.read(0);
            } finally {
                input.close();
        @Override protected void done() {
            try {
                target.setIcon(new ImageIcon(get()));
            } catch(Exception e) {
                JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
        //demo
        public static void main(String[] args) throws IOException {
            final URL url = new URL("http://blogs.sun.com/jag/resource/JagHeadshot.jpg");
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch(url);
        static void launch(URL url) {
            JLabel imageLabel = new JLabel();
            final JProgressBar progress = new JProgressBar();
            progress.setBorderPainted(true);
            progress.setStringPainted(true);
            JScrollPane scroller = new JScrollPane(imageLabel);
            scroller.setPreferredSize(new Dimension(800,600));
            JPanel content = new JPanel(new BorderLayout());
            content.add(scroller, BorderLayout.CENTER);
            content.add(progress, BorderLayout.SOUTH);
            JFrame f = new JFrame("ImageLoader");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(content);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            ImageLoader loader = new ImageLoader(url, imageLabel);
            loader.addPropertyChangeListener( new PropertyChangeListener() {
                 public  void propertyChange(PropertyChangeEvent evt) {
                     if ("progress".equals(evt.getPropertyName())) {
                         progress.setValue((Integer)evt.getNewValue());
                         System.out.println(evt.getNewValue());
                     } else if ("state".equals(evt.getPropertyName())) {
                         if (SwingWorker.StateValue.DONE == evt.getNewValue()) {
                             progress.setIndeterminate(true);
            loader.execute();
    abstract class IIOReadProgressAdapter implements IIOReadProgressListener {
        @Override public void imageComplete(ImageReader source) {}
        @Override public void imageProgress(ImageReader source, float percentageDone) {}
        @Override public void imageStarted(ImageReader source, int imageIndex) {}
        @Override public void readAborted(ImageReader source) {}
        @Override public void sequenceComplete(ImageReader source) {}
        @Override public void sequenceStarted(ImageReader source, int minIndex) {}
        @Override public void thumbnailComplete(ImageReader source) {}
        @Override public void thumbnailProgress(ImageReader source, float percentageDone) {}
        @Override public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {}
    }

  • [advance question] loading a swf in adobe Air, which loads an image with "componentloader"

    Good evening all,
    I think this is a complex issue.
    I have adobe air application which loads a SWF I made.
    Inside this SWF I have used the "component LOADER" to load
    something with "ContentPath=image.jpg" for example.
    But the swf loaded in the Adobe air works, but does not load
    the "ContentPath image"...
    (it does load and display it when it this swf is run outside
    adobe Air)
    I need it to be dynamic like this, so if eventually I Include
    it in the package it won't help much...
    I just intend to replace an image background from this loaded
    swf file!
    Thanks!
    Edit:
    At this time of the editing, I fear and realize
    something....I have been using Actionscript2 for the .SWF file,
    could it be why it does not works???
    If its problematic, is there a simple way like telling it to
    read actionscript2, rather than transforming everything??
    edit2:
    I found this on the official AIR FAQ:
    Will Flash version 8 and below SWF files run in Adobe AIR?
    Yes. However, the Adobe AIR APIs are only exposed to Flash
    content via ActionScript 3 / AVM2, and thus Flash 8 / AVM1 SWFs
    will be able to run, but they will not have direct access to the
    Adobe AIR APIs.
    source:
    source
    faq Adobe
    it seems it should works!!??
    Edit3:
    nope I confirm at least some code made in Actionscript2
    works.
    I am sure this code needed to be changed for working in
    actionscript3, so "actionscript2" code works in Adobe Air.
    The problem of not loading my image must come from something
    else!!??

    Good Morning all!
    Hilarious....
    I tried so much to think maybe Adobe Air does not like a SWF
    using actionscript2, or it does not load any "external image from a
    swf", etc...
    None of that!
    I just in FLASH in the ComponentLoader....I did put simply
    the ContentPath at "myimage.jpg"....
    Of course I had to use the absolute path like
    "c:\\myfolder\\myimage.jpg"
    Of course aswell it works now!!!

  • Problem loading material master (IS Mill) data from ECC to BI

    Hi Gurus,
    We have a problem loading Material master data from ECC to BI 7.0 SP 18.
    The scenario is :
    The ECC is with IS Mill... due to which the Material field MATNR is of length 40 instead of standard 18 characters.
    That is data element MATNR has 18 chars and its output length is 40 chars.
    When is table MARA browsed using SE16, the material with more than 18 chars.... shows only first 18 characters and are ended with !.
    OMSL setting shows length as 40.
    When the extractor checker runs 0MATERIAL_TEXT or 0MATERIAL_ATTR it gives correct output ..... which is more than 18 characters... not ended with !
    Till here no problem.
    On BI side, after replication of the datasource, i checked data element MATNR ... but it has length as 18 chars and output length as 18 chars.
    OMSL setting cannot be set more than 18.
    Infopackage has pulled data till PSA successfully. I checked the PSA data .... here to the material with more than 18 chars is ended with !.
    When the data is further pushed to 0MATERIAL infoobject, it throws following error for all materials irrespetive of its length (example below):
    0MATERIAL : Data record 768 ('SIT_PL_B01L_10_01!E '): Version 'SIT_PL_B01L_10_01! ' is not valid
    0MATERIAL : Data record 165 ('RLIRS52 E '): Version 'RLIRS52 ' is not valid
    Diagnosis
         Data record 768 & with the key 'SIT_PL_B01L_10_01!E &' is invalid in value 'SIT_PL_B01L_10_01! &' of the attribute/characteristic 0MATERIAL.
    System Response
         The system has recognized that the value mentioned above is invalid, and has processed this general error message. A subsequent message may give  you more information on the error. This message refers to the same value, even though it does not state this explicitly.
    I did search for SAP note related to this... but could not find any.
    There is one SAP note (Note 960868) which mentions about this, but the correction was then shipped with BI SP 9.... we are running on SP 18.
    Requesting you all experts for help.
    Best Regards,
    Deepak

    Hi,
    follow bellow steps:
    1. you need to activate the Datasouce in BI side.
    Goto RSA1>  Datasource> Select Datasource> Double click> Check fileds and Activate.
    2. Replicate the Datasource into BI side.
    3. Check the RFC connections by useing SM59.
    Regards.

  • Loading child SWFs with TLF content (from Flash CS5.5) generates reference errors in FB4.6

    I am currently producing e-learning content with our custom AS3-Framework.
    We normally create content files in Flash CS5.5 with dynamic text fields, which are set at runtime from our Framework (AS3 framework in FB4.6).
    Now we are in the progress of language versioning, and since one of the languages is Arabic we are changing the dynamic text fields to TLF fields.
    Then all my problems started.
    In Flash I have chosen to include the TLF engine and to export in frame 2.
    (see to: http://helpx.adobe.com/flash/kb/loading-child-swfs-tlf-content.html )
    I get this error:
    VerifyError: Error #1053: Illegal override of getEventMirror in flashx.textLayout.elements.FlowLeafElement.
                at flash.display::MovieClip/gotoAndPlay()
    I guess it is because our framework wants to gotoAndPlay before the TLF engine has been loaded.
    Can this be it?
    Any good suggestions on how to handle loading child SWFs with TLF content.

    Please refere to the following articles .. you may find some help.
    http://www.stevensacks.net/2010/05/28/flash-cs5-tlf-engine-causes-errors-with-loaded-swfs/
    http://www.adobe.com/devnet/flash/articles/preloading-tlf-rsl.html
    I also faced similar problem and posted a question at the following link, but, I still couldn't find the solution.
    http://forums.adobe.com/message/4367968#4367968

  • Problem Loading All Images

    I've created a game and pretty much everything works, except that every once in a while, not all the images load, which obviously causes a big problem, bc if you can't see the characters you're supposed to be interacting with, everything breaks. I've tried using MediaTracker. I add every image to the media tracker object and wait for each of them, which didn't always work. Then, just as a test, I tested the width of each Image after it loaded to make sure that it did load. If any of the widths were 0, the program would exit. This worked, at least on my computer, but, when I run it online, it still doesn't always load every image.
    Is there something obvious that I'm missing? Thanks

    zrawson wrote:
    sorry about that - btw i tried the ImageIO way and it worked, but now my GIF's don't animate. any ideas for that new problem?
    thanksGasp! Where in the previous posts do you mention animated gifs? Seriously, it's a non-trivial exercise to read all the data in an animated gif using ImageIO. For those, I would stick with the old way.

  • A different version of the problem loading raw images edited in LR 3.3 to CS4

    I have recently upgraded LR2 to LR3 (now up to 3.3). I have CS4 extended and ACR 5.7. Haven't printed for some months now because I have moved overseas (UK to Malaysia) until yesterday. The printing was a disaster because the colours printed are not as the finished print files. So I have been investigating (calibrated my monitor etc) and then I noticed any LR3 edited Nikon raw file when edited in CS4 carrying across the LR3 settings was so bad and very different to the LR3 version. The nice vibrant LR3 image was dull with inaccurate and toned down colours as though a piece of grey glass had been put in front of it.
    So I have read as many of the forum questions on the related issue and have not found an answer or more to the point a solution. I run a MacPro with the latest Snow Leopard OS but all of the fixes I have tried don't change the problem. Is it a compatability problem or an error by me due to some obscure setting or something else? Never had the problem with LR2 and the same Photoshop CS4 software.
    I also lost most of my LR2 edit setting for a good percdentage of the edited files when I upgarded to LR3. Don't know if this is related or another problem as now I have to redo all of the files that have lost their edited changes.
    I would appreciate any help in solving this/these issues.

    The question posted by me has not been answered and I am pulling my hair out trying to have my Lightroom/CS4 image processing work flow that has worked for nearly 2years back to normal.
    I might as well not have lightroom as opening a lightroom 3.3 edited image in CS4 removes all of the editing done in lightroom. This appears to be true since I upgraded to v 3.3. As one person who posted in another theme suggested I tried saving a Tiff of the lightroom changes which I did via Nik Efex (I do not know how to save a raw file as a Tiff in LR as I don't do it as part of my normal workflow) but it reverted to the totally unedited version of the raw file when it opened in CS4.
    Is there a problem with LR3.3 that Adobe are keeping quiet on. There was no warning when I picked uop the 'updated software' message when I opened LR a short while back. Now I am unable to use either as the processing route I use in LR is very fast compared to CS4 (in my view) and I do not have the time to completely change my work flow. I could revert back to LR3.2 but that may lose all of my editing and cause me no end of problems.
    As this is an Adobe forum I thought these problems would be discussed with a lot more answers.

  • Having problem loading Aol mail with Firefox ver 4. Keep getting error 8 msg. Any ideas?.

    INstalled Firefox 4 and now cannot laod the aol mail website. I can use ms explore with no problem. Get error msg 8 Problem loading application. AOL itself loads fine, just not mail.

    INstalled Firefox 4 and now cannot laod the aol mail website. I can use ms explore with no problem. Get error msg 8 Problem loading application. AOL itself loads fine, just not mail.

  • Problems setting email headers with javax.mail.*

    I'm trying desperatly to send HTML emails with javax.mail but I simply can't. No matter what I do, no matter how and where I set the headers it always come out as text.
    Here's a sample code:
    try {
              Properties props = System.getProperties();
              props.put("mail.smtp.host", "smtp.ability.com.br");
              Session session = Session.getDefaultInstance(props, null);
              Message msg = new MimeMessage(session);
              msg.setHeader("Content-Type", "text/html");
              msg.setRecipient( MimeMessage.RecipientType.TO, new InternetAddress("[email protected]") );
              msg.setFrom( new InternetAddress("[email protected]") );
              msg.setSubject("teste");
              msg.setText("<b>testeeeeeeeeeeeee</b>");
              Transport.send( msg );
              } catch( Throwable t ) {
                   System.err.println(t);
              }and here's the resulting email:
    Return-Path: <[email protected]>
    Delivered-To: [email protected]
    Received: (qmail 5895 invoked by uid 510); 21 Dec 2004 16:41:49 -0000
    Received: from [email protected] by relay03.dominal.com
    Received: from unknown (HELO christian) (200.217.110.124)
      by 0 with SMTP; 21 Dec 2004 16:41:48 -0000
    Message-ID: <20590970.1103647309922.JavaMail.christian@christian>
    From: [email protected]
    To: [email protected]
    Subject: teste
    Mime-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <b>testeeeeeeeeeeeee</b>What am I missing here?
    Thanks in advance,
    Christian

    msg.setText("<b>testeeeeeeeeeeeee</b>");R
    eplace that
    bymsg.setContent("<b>testeeeeeeeeeeeee</b>",
    "text/html");
    Thanks DrClap, but that's not exactly the solution I'm looking for, cuz I would have to hard-code that header.
    I have an Email class that I use as a wrapper for the javax.mail API, and I wanna be able to have a setHeader() method that works to enable the users to set the content-type of the text (or HTML) portion of the email, even when there are attachments. How can I achieve this?

  • Load/Import images with Lingo in "running time"

    I would like to do the following:
    When I start a Shockwave application on my website, I want to
    load an images from the server and include it in my movie.
    How can I do it? (The image is not initially on the movie).
    On the other hand (this one is more difficult): If I have a
    3D scene: Can I put such image in a wall of my 3D scene
    dynamically?
    Thank you a lot.

    To load an external image in your movie, you can set the
    .fileName property of a bitmap member. It would help to preload the
    image file, so that it is available locally before setting the
    filename. Look up preloadNetThing().
    To show an image on a wall in a 3D scene, you need to make
    the image into a texture, make the texture part of a shader, and
    use that as the shader of the wall mesh. Here's a movie that does
    something like that, using images already available in a castLib:
    http://nonlinear.openspark.com/tips/3D/zoetrope/

  • Problem loading xml file with method

    I am using this method to insert into table of xmltype
    INSERT INTO xml_table
    VALUES (XMLType(bfilename('XMLDIR','Test_xml.xml'),
    nls_charset_id('AL32UTF8')));
    xml gives error
    <?xml version="1.0"?>
    <!--<!DOCTYPE metadata SYSTEM "http://www.esri.com/metadata/esriprof80.dtd">-->
    <metadata xml:lang="en"><Esri><MetaID>{299847D5-3DDC-4375-9469-607DC669DD6E}</MetaID><CreaDate>20091029</CreaDate><CreaTime>12035600</CreaTime><SyncOnce>FALSE</SyncOnce><SyncDate>20091029</SyncDate><SyncTime>12054400</SyncTime><ModDate>20091029</ModDate><ModTime>12054400</ModTime></Esri><idinfo><native Sync="TRUE">Microsoft Windows XP Version 5.1 (Build 2600) Service Pack 3; ESRI ArcCatalog 9.3.0.1770</native><descript><langdata Sync="TRUE">en</langdata><abstract>REQUIRED: A brief narrative summary of the data set.</abstract><purpose>REQUIRED: A summary of the intentions with which the data set was developed.</purpose>
    but when i remove
    <!--<!DOCTYPE metadata SYSTEM "http://www.esri.com/metadata/esriprof80.dtd">-->
    it successfully executes and value is inserted of xmltype
    Please suggest how i can insert the original xml without error.

    SQL> call UTL_HTTP.set_proxy('proxy.mydomain.com:8080', NULL);
    Call completed.
    SQL> declare
    2 t_result
    3 varchar2(4000);
    4 begin
    5 t_result := utl_http.request('http://www.fgdc.gov/metadata/fgdc-std-001-1998.dtd');
    6 INSERT INTO xml_table
    7 VALUES (XMLType(bfilename('XMLDIR','bas_street_segment.xml'),
    8 nls_charset_id('AL32UTF8')));
    9 end;
    10 /
    declare
    ERROR at line 1:
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1577
    ORA-12545: Connect failed because target host or object does not exist
    ORA-06512: at line 5
    It is giving error, we made a call to UTL_HTTP.set_proxy, it is ok.
    Is there a way that i have dtd file, fgdc-std-001-1998.dtd on local machine and dtd gets validated when i
    insert the xml without need for oracle to go to internet. I need both dtd validation with internet and from local path options.
    Please help, thankx for timely help
    sivaram

Maybe you are looking for

  • Move transaction open interface

    I import move transaction through Move transaction open interface. The 11i open interface user guide tells that for WIP transaction completion, I need to insert a row into WIP_MOVE_TXN_INTERFACE, and also a line into CST_COMP_SNAP_INTERFACE. What is

  • LR2 and PS4 - merging to HDR, merge to Panaorama and Edit in Layers not working

    Hi, I've recently upgraded from LR to LR2.1 and Photoshop CS to CS4. I've been trying to multi-select images from LR2 and edit them as HDR and Panoramas using the "Edit in->" merging options. None of them seem to work. I can see PS CS4 being opened,

  • Can't add to collaborative playlist

    I am trying to use the collaborative playlist feature for the first time. I made my playlist collaborative and sent the link to a freind. When she clicks on the link she goes to a URL on play.spotify.com and she can see the playlist but can't add to

  • Malicious user (troll) is sending out my Skype nam...

    Hello, people!  I am loving Skype, but I have an issue. Recently, a user with malicious intent entered one of the group conversations I'm in on Skype. This user then proceeded to copy all the usernames of this group's members.  This user has programm

  • Direct linking to Blog

    So, I've been wondering how to do something for awhile.... So, I want to be able to directly link to a BLOG via the Navigation bar at the top of a page. I want to be able to do this without having to go through a module that THEN links to the OVERALL