URL in applets

Im creating a client - server program with the client being an applet.
On the server the applet class files are in, say c:/webServer/applet . Now I want to access pictures in, for example c:/webServer/images . So they are on the host computer but not in the codebase directory. Ive tried a few things but Im not that used to working with URLs and especially not on applets where there are security restrictions as well.
Appriciate any help or tips.

Can someone please type the code(it shouldnt be more than one line).
Ive tried
ImageIcon(new URL(dealer.MyApplet.getCodeBase(), "../" + path), description);
but that just gives an exception.
this one works
java.net.URL imgURL = MyApplet.class.getResource(path); (then putting it in an ImageIcon constructor)
but I dont know how or if I can get to the folder I want with that one.
Would realy appreciate an answer since I need it soon and don't have time to search(got ALOT to do at the moment).

Similar Messages

  • Can't display a URL web applet in Double Column

    I've created a URL web applet which displays in the Opportunities homepage. The problem is that the web applet do not displays in double Column, it is only displayed in single column, therefore I only see the half of the applet.
    When I go to Administration/ Application Customization / Opportunities / Web Applets... and change from Single Column to Double and save, it still appears in single column. If I go back to edit the web applet it says : Single column. I don't get it, everytime I change from single to double, CRM OD does not save the changes.
    Does anyone knows a solution?

    hi,
    i have the same problem. Did you solve it?. Please let me know...
    regards,
    MC

  • URL and applet

    How can i open an url with applet and view the data it has?
    thank you for help

    /*    <applet code="AppletRead" width="400" height="300"></applet>
    *    use >appletviewer AppletRead.java
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class AppletRead extends JApplet {
      static boolean isApplet = true;
      public void init() {
        String file = "AppletRead.java";
        String address;
        if(isApplet)
          address = getCodeBase() + file;
        else
          address = "file:" +
                     System.getProperty("user.dir") +
                     System.getProperty("file.separator") +
                     file;
        JEditorPane editorPane = new JEditorPane();
        try {
          URL url = new URL(address);                  // either of these two
    //      URL url = getClass().getResource(file);    // methods works okay
          System.out.println("url = " + url);
          editorPane.setPage(url);
        catch(MalformedURLException murle) {
          System.out.println(murle.getMessage());
        catch(IOException ioe) {
          System.out.println(ioe.getMessage());
        getContentPane().add(new JScrollPane(editorPane));
      public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JApplet applet = new AppletRead();
        f.getContentPane().add(applet);
        f.setSize(400,300);
        f.setLocation(300,400);
        isApplet = false;
        applet.init();
        applet.start();
        f.setVisible(true);
    }

  • Open URL from Applet

    Hi, I have read through past posted messages to try to figure out my problem, but it has not helped. I am trying to open up a browser depending on which link is selected in the drop-down list box. Nothing happens when I click the button so I have hard-coded the link to just see if a browser will open. And, still, nothing happens.
    Here is my code:
    public class Searcher extends Applet implements ActionListener {
      static String[] siteNames = {
        "AltaVista",
        "Excite",
        "HotBot",
        "Infoseek",
        "WebCrawler",
        "Yahoo",
        "Lycos"};
      static String[] siteURLs = {
        "http://www.altavista.com",
        "http://www.excite.com",
        "http://www.hotbot.com",
        "http://www.infoseek.com",
        "http://www.webcrawler.com",
        "http://www.yahoo.com",
        "http://www.lycos.com"};
      Choice searchChooser;
      Button searchButton;
    public void actionPerformed(ActionEvent evt) {
       Button source = (Button) evt.getSource();
        if (source.getLabel().equals("Go Search!")) {
            int indx = searchChooser.getSelectedIndex();
            try {
                 URL url = new URL("http://www.lycos.com");
                AppletContext browser = getAppletContext();
                browser.showDocument(url);
            } catch (MalformedURLException e) {
                System.err.println("Bad URL: " + siteURLs[indx]);
    }

    http://java.sun.com/docs/books/tutorial/applet/overview/index.html
    See "What applets can and can't do" and follow the link.

  • Open url from applets

    Hello friends
    i have one very important job to do i would like my applet to open a browser window with the url that i specify in the textfield of my applet
    this is how it starts i open the applet that has a textfield and a button i enter the url in this textfield now i want my applet to initiate a browser window it could be ie or netscape with the url specified in my applet textfield
    i hope u got my point
    thanks in advance
    hari

    URL yourURL = new URL ("www.YOURChoiceOfURL.COM");
    getAppletContext().showDocument(yourURL, "_self" );     
    just lookup the parameter of the showDocument method at the java api list
    hth,
    paulo

  • Dispalying URL in Applet Window

    Hi
    How can I display URL content in applet window separate from the browser.
    Thanks in advance

    It would depend on what the content is at the end of that URL. It could be anything.

  • How  applet write file in local system by URL instead of FileOutputStream()

    hi,
    how can applet write a file in local system through URL instead of FileOupStream()
    plz.....plz.....plz......
    URL url = new URL(" file://c:/temp.txt");
    in this url how applet can write
    plz....

    URL uses http to cummunicate, this means you can send and receive data using the http
    protocol.
    The OS doesn't do anything with this, you need a http server to interpret these messages
    and take appropriate action (with server side script or CGI).
    So if the client has a http server installed and has server side script thad does
    something with your http request (that's what a url does) than it is possible.
    Since both having a http server , server side script and or CGI have nothing to do with
    signed applets I will not answer your question here.
    But the mail reason I won't answer it is because it makes no sence to use a URL to write
    to the local file system.

  • How to display a dynamic image file from url?

    Hey,I want to display a dynamic image file from url in applet.For example,a jpg file which from one video camera server,store one frame pictur for ever.My java file looks like here:
    //PlayJpg.java:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class PlayJpg extends Applet implements Runnable {
    public static void main(String args[]) {
    Frame F=new Frame("My Applet/Application Window");
    F.setSize(480, 240);
    PlayJpg A = new PlayJpg();
    F.add(A);
    A.start(); // Web browser calls start() automatically
    // A.init(); - we skip calling it this time
    // because it contains only Applet specific tasks.
    F.setVisible(true);
    Thread count = null;
    String urlStr = null;
    int sleepTime = 0;
    Image image = null;
    // called only for an applet - unless called explicitely by an appliaction
    public void init() {
                   sleepTime = Integer.parseInt(getParameter("refreshTime"));
              urlStr = getParameter("jpgFile");
    // called only for an applet - unless called explicitely by an appliaction
    public void start() {
    count=(new Thread(this));
    count.start();
    // called only for applet when the browser leaves the web page
    public void stop() {
    count=null;
    public void paint(Graphics g) {
    try{
    URL location=new URL(urlStr);
    image = getToolkit().getImage(location);
    }catch (MalformedURLException mue) {
                   showStatus (mue.toString());
              }catch(Exception e){
              System.out.println("Sorry. System Caught Exception in paint().");
              System.out.println("e.getMessage():" + e.getMessage());
              System.out.println("e.toString():" + e.toString());
              System.out.println("e.printStackTrace():" );
              e.printStackTrace();
    if (image!=null) g.drawImage(image,1,1,320,240,this);
    // called each time the display needs to be repainted
    public void run() {
    while (count==Thread.currentThread()) {
    try {
    Thread.currentThread().sleep(sleepTime*1000);
    } catch(Exception e) {}
    repaint(); // forces update of the screen
    // end of PlayJpg.java
    My Html file looks like here:
    <html>
    <applet code="PlayJpg.class" width=320 height=240>
    <param name=jpgFile value="http://Localhost/playjpg/snapshot0.jpg">
    <param name=refreshTime value="1">
    </applet>
    </html>
    I only get the first frame picture for ever by my html.But the jpg file is dynamic.
    Why?
    Can you help me?
    Thanks.
    Joe

    Hi,
    Add this line inside your run() method, right before your call to repaint():
    if (image != null) {image.flush();}Hope this helps,
    Kurt.

  • Applet does not start after JRE 1.5 installation

    Hi,
    When I go to my webpage where I have an applet that requires Java 1.5..the browsers are prompting for Java installation (ActiveX component install on IE or Firefox plugin for JRE installation). But once the Java install completes the applet does not start automatically. The same code used to work nicely with Java 1.4. The applet used to automatically start and run once the JRE install completed. But with JRE 1.5 it does not start. If I do a refresh on the browser it again prompts for java installation. If I open new browser window and go to the URL the applet starts. Please let me know how to get the applet to start automatically after JRE 1.5 installation.
    Thanks,
    Vijay

    We figured out the problem. the CLASSID was not the right one. Once we changed it...its working fine.
    Vijay

  • Applet does not start after Java 1.5 installation

    Hi,
    When I go to my webpage where I have an applet that requires Java 1.5..the browsers are prompting for Java installation (ActiveX component install on IE or Firefox plugin for JRE installation). But once the Java install completes the applet does not start automatically. The same code used to work nicely with Java 1.4. The applet used to automatically start and run once the JRE install completed. But with JRE 1.5 it does not start. If I do a refresh on the browser it again prompts for java installation. If open new browser window and go to the URL the applet starts. Please let me know how to get the applet to start automatically after JRE 1.5 installation.
    Thanks,
    Vijay

    We figured out the problem. the CLASSID was not the right one. Once we changed it...its working fine.
    Vijay

  • No communication between applet - servlet

    hi
    my applet and my servlet is not at all communicating in the browser.
              any body knows how to solve this problem?
              in my applet code:Jus i am pasing as name string to invoke the serlvet via URL
              String location = "http://ctp-vi0275:8880/HandlePassword?"+"Name=XXX";
              URL testServlet = new URL( location );
              URLConnection servletConnection = testServlet.openConnection();
              servletConnection.setDoInput(true);
              servletConnection.setDoOutput(true);
              servletConnection.setUseCaches (false);
              servletConnection.setDefaultUseCaches (false);
              servletConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              servletConnection.connect();
              i have changed server.xml file to listen the port number 8880.(in tomcat)
              in my servlet code:
              doGet Method in servlet
              String str = req.getParameter("Name");          
              System.out.println(str);
              here i am jus printing the name
              but when i run my applet is not at all invoking the serlvet - HandlePassword.I have placed the
              servlet in ROOT\web-inf\classes\HandlePassword
              in web.xml
              <web-app>
              <servlet>
              <servlet-name>HandlePassword</servlet-name>
              <servlet-class>HandlePassword</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>HandlePassword</servlet-name>
              <url-pattern>/HandlePassword</url-pattern>
              </servlet-mapping>
              </web-app>
              where i am doing wrong here?

    You do following things and let me know:
    1. Does the servlet work when you type "http://ctp-vi0275:8880/HandlePassword?Name=XXX" in your browser?
    2. Run applet using appletviewer. Does it work?
    3. If it works using appletviewer then enable java console in your browser and see error stacks if any.
    4. If there are applet security errors on java console, try creating servlet URL in applet code by calling getDocumentRoot() method and see what happens.

  • SOS, how to make hot link by text ,not button or list in applet

    Now i m making one applet, have 12 months histogram figure, there is 1,2,3,....12 month below
    the histogram, when i hit one number, i can get to one month page, example, i hit 1 month, i
    can get to i month's page there are 31 days in january.
    through jdk document, i know the showDocument(URL ur,String target) method just permit Button and List do,other not do.
    how i can hit text to link?

    hi, watertownjordan, i follow your method, do that like the following,
    but running-error,and nothing do!
    can u give me a example?
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.URL;
    public class Test extends Applet{
    public void init() {
    //resize(250,250);
    // HyperLink hy=
    try{
    HyperLink hy=new HyperLink("first",new URL("http://211.152.130.189:8001"),this);
    add(hy);
    }catch(Exception e){}
    class HyperLink extends Label implements MouseListener {
    URL theLink;
    Applet that;
    public HyperLink(String text, URL link,Applet that)
    super(text);
    this.that=that;
    theLink = link;
    addMouseListener(this);
    public void mouseClicked(MouseEvent e)
    that.getAppletContext().showDocument(theLink);
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}

  • URL problem with Java Plugin 1.4.1

    To whom it may concern:
    We are developers working in java and we are experiencing a problem with the new Java plug-in (version 1.4.0) that are not able to solve ourselves:
    We have an applet that needs to read URL�s. When we run the applet locally, this URL is:
    "file:/C:/proof/hunter%20media/images/classic.ski". When we try to open an stream to this URL it doesn't work. The message that we obtain is:
    access denied (java.io.FilePermission C:\proof\hunter media\images\classic.ski read)
    but all the permissions are OK. Also, if we remove the whitespace from URL the applet works OK.
    We have tested the applet in Windows XP with Netscape 7.0, Internet Explorer 6.0.2 and tha Java plugin version is 1.4.0.
    Is there any problem with the whitespaces in URL opened locally?
    Please advice,
    Kind regards,
    Fernando

    Doesn't a url require "file://....?

  • URL problem with Java plugin 1.4.0

    To whom it may concern:
    We are developers working in java and we are experiencing a problem with the new Java plug-in (version 1.4.0) that are not able to solve ourselves:
    We have an applet that needs to read URL�s. When we run the applet locally, this URL is:
    "file:/C:/proof/hunter%20media/images/classic.ski". When we try to open an stream to this URL it doesn't work. The message that we obtain is:
    access denied (java.io.FilePermission C:\proof\hunter media\images\classic.ski read)
    but all the permissions are OK. Also, if we remove the whitespace from URL the applet works OK.
    We have tested the applet in Windows XP with Netscape 7.0, Internet Explorer 6.0.2 and tha Java plugin version is 1.4.0.
    Is there any problem with the whitespaces in URL opened locally?
    Please advice,
    Kind regards,
    Fernando

    Hi Fernando,
    What do you mean u removed the whitespaces. I am actually trying to work my way around a similar problem. I am trying to access a URL from a locally loaded applet. But i get a security exception too.
    http://osmv.soe.umich.edu/blueskies/kgs99/kgs99.txt
    how do i strip it of whitespace?
    Thanks,
    Shantanu

  • Applet can't be instantiated on IE browser.

    I have created an SWING Applet (JApplet). It works fine inside JDeveloper IDE using the Appletviewer but when I deploy it and I try to launch it through the Internet Explorer browser I get the following message:
    "Applet can't be instantiated".
    I'm working with JDeveloper 3.1.1.2
    Can somebody help me out with this? I will really appreciate it.
    null

    In the java console of IE are you getting any class not found errors?
    Please refer to the following URL (Swing Applet Test ) to check whether your browser supports swing classes or not.
    http://java.sun.com/products/jfc/tsc/articles/getting_started/applet_test.html
    Another way to create and run Swing applets in IE or netscape is to use Java Plug-in.
    null

Maybe you are looking for

  • IDCO--xi--external system

    hello friends, Please give me the steps to config outboudn idoc (out from R/3). just installed the 2004s. what steps to do. what i know 1) create port in xi 2) create rfc in xi to connect to R/3 How to create RFC in R/3 ( what connection i have to ch

  • Magazines for iPhone 4 through 6+

    Hello, I'm designing a magazine for iPhone 4 through 6+ and having some questions. I need the better resolution for each phone so I'm making a folio for each iPhone screen resolution. When I get them published on an iPhone 6, for example, I gonna see

  • Running total as alphabets

    I want to put a running total as alphabets. For Example 1. Question Title      A) Option 1      B) Option 2      C) Option 3 2. Question Title      A) Option 1      B) Option 2      C) Option 3 I got the running numbers for Question Title but i am no

  • Which item is selected?

    Hello, In Dreamweaver CS3 we have a drop-down list in a form. When the user selects an element in the list, we need to determine which element was selected; specifically we need the text string of the selected element. How do you do this? The raw cod

  • Navigation with Galileo

    Does support the Nokia lumia the new Galileo satelite navigation ? http://en.wikipedia.org/wiki/Galileo_(satellite_navigation)#Satellite_names Solved! Go to Solution.