Specifying file location on uploaded applet

Hi guys, as a test Im trying to get an applet to display an image. I have packed the applet and image file into a jar file. The image file was placed into a folder called images when the jar file was created. I have checked this using the jar tf command, and it clearly shows the file anim1.gif within the directory called images. Within the code of the applet, I find and load the image using:
ImageIcon icon = null;
URL iconURL = ClassLoader.getSystemResource("images/anim1.gif");
if (iconURL != null)
System.out.println( "found" );
icon = new ImageIcon( iconURL );
else
System.out.println( "not found" );
However, when i check the java console, i always get the message 'not found'. From reading the tutorials etc...i cannot see what im doing wrong. The image is definatley packed into the folder 'images' within the jar file, and u can see that the code gives this directory to look in. Am i doing something stupidly wrong??
Any help would be much appreciated!!
dug \8^D

Try this way:
URL picURL1 = getClass().getResource("images/rightArrow.gif");
      if(picURL1 != null && picURL2 != null) {
         icon1 = new ImageIcon(picURL1);

Similar Messages

  • Specify Remote Location for PrintWriter (applet question)

    Hello,
    I am trying to use a Java applet to access a URL, read in its text content, and save it to a file. The applet is run off an online host (our school server) so I made it a signed JAR file so I could access other hosts. However, here is my problem. The applet itself is in a remote location (our school server, a unix server). I can edit the directory via SSH to add files, and these files become accessible via my homepage (where I'm running the applet from in my browser). But what I need to do is write a file IN THE SAME DIRECTORY as the applet is being run from (ie, the remote directory). But I find that when I run the applet from my browser, it instead by default saves the file I've written to in the local machine's home directory (the desktop). How can I force the applet to save/write to a file in that remote directory (I have the permissions set up on it so that non-owner can write to the directory).
    Maybe this isn't possible. I wasn't sure. Here is my code:
          //get URL containing the escape table
          URL inputURL = new URL(inputLocation);
          //make connection to the URL
          URLConnection inputCon = inputURL.openConnection();
          //save URL's contents as text file in same directory
          BufferedReader inputStream = new BufferedReader(new InputStreamReader(inputCon.getInputStream(), "UTF-8"));
          //save with same name as URL file
          File file = new File(inputURL.getFile());
          String filename = file.getName();
          PrintWriter outputStream = new PrintWriter(new File(filename), "UTF-8"); //this didn't work either: outputStream = new PrintWriter(filename, "UTF-8");
          //line of current input
          String line = null;
          //output text file to local text file line-by-line
          while((line = inputStream.readLine()) != null)
            System.out.println("line=" + line); //TEST TO MAKE SURE ACTUALLY READING FILE
            outputStream.println(line);
          }According to my System.out.println, it IS actually accessing the URL and reading each line from the URL's text file correctly, and outputStream.println(line) is correctly printing to the file; it's just doing it in the wrong place!
    Also, I should specify: I can't hard encode the file location. It could be anywhere in my html directory. Rather, I want a way to save it in the same directory as the applet was deployed from.

    It's for an assignment. All our assignments have to be applets and run from our unix server. I have to access a URL and get data from it, then create that file, then use that file as a reference table for something else.
    The tragic part is I think I have everything else working, but I've no way to test it, as I cannot figure out how to access URLs in jgrasp (my IDE - just running the java file itself as an applet within the IDE has the error message about being unable to connect to the URL, since the applet is not signed, but I've no way how to get around that within the IDE itself) so I am testing it directly on the server as a signed jar file so I can at least access the urls.
    The requirements stated:
    "make a text file (UTF-8 encoding) of the file name t in the same directory where an applet is deployed; "
    # A program must be written as an applet in Java. Other programming languages such as JavaScript cannot be used.
    # The applet must be deployed on the ITS Web server
    I could be missing something, honestly. >_< I might have a word with the TA. I'm just really frustrated since I have everything else working.

  • How do I specify file locations in a structure application?

    I want to export a structured Frame file to XML, using a structure application that I create. I have a DTD, a read/write file, and a template file, all stored on a network drive. I would like to specify the locations of these files using the notation \\MyServer\folder\...\folder\name.dtd, etc to make the application independent of the drive mapping. I can do this for the read/write file and the template file, but FrameMaker complains when I specify the DTD file in the same way. If I change the path for the DTD file to be R:\...\folder\name.dtd, then FrameMaker does not complain about it but apparently sees the read/write and template files just fine.
    Why is this? Am I doing something wrong in the path specification?
    I am using FrameMaker 9.0.3 on Windows XP with all service packs.
    Thanks,
    Van

    David,
    Yes, I also used the form K:\folder\...\name.dtd, and it works. The problem down the line is that FrameMaker inserts that text into the <!DOCTYPE ... > element, which is normally OK; however, when I open the file in Dreamweaver, DW changes the statement to <?DOCTYPE ... ?>, which is the incorrect form. Subsequent testing indicated that Dreamweaver did this because of the colons, as in K:. Why? I do not know, except maybe Dreamweaver is making some assumptions about what it expects to see in the file.
    Michael,
    I tried changing the backward slashes to forward slashes, but that did not work also. But in that process, I discovered that the problem was due to spaces in the names of the folders and file names. Replacing the spaces with %20 did not work, but removing them or replacing them with underscores DID work.
    So, now I have the locations specified with BACKward slashes and NO SPACES in folder and file names. This works just fine. Moreover, FrameMaker creates a doctype statement with FORWARD slashes in the path name, which is more universal.
    So, for the time being, I am very happy.
    Thanks for your help,
    Van

  • Programmatically specify file location within ear file

    Hi guys,
    I am deploying an ear file under weblogic 6.1 and in part of the code I need to parse an xml file however, I can't figure out how to specify the path to the file. Whatever I try I always get an exception telling me the file cannot be found. The file itself resides within WEB-INF in the applications jar file which itself resides within the ear.
    I don't know how to specify the files location.
    Please help!
    Simon.

    Hi Simon,
    I'm not sure if this will help - but I have had similar problems and am happy to share my experiences with you and hope they help you. (my test were done on JRun 3.0 - but am sure the behavior under weblogic is similar)
    I am not sure what method you are using for accessing your xml file and what the package structure of you apps is but I assume that you are either doing a
    <code>
    String fileName = "myFile.xml";
    File f = new File(fileName);
    or
    URL u = this.getClass().getResource(fileName);
    </code>
    I found problems with both these methods when deploying as a web app. The first method places the file in
    <code> {JRunPath}\servers\default </code>
    directory (which it should as the spec by default creates the file in the users default directory)
    and the second creates a URL that does not correctly map to the location (see my post http://forum.java.sun.com/thread.jsp?forum=136&thread=184500)
    neither of these is suitable for deploying a webapp. The only way to locate the resource seems to be to use either
    <code>
    fileName = ServletContext.getRealPath(fileName);
    or
    URL url = ServletContext.getResource(fileName);
    </code>
    This does leave open this issue on how to pass the servlet context down to the specific class within your application that loads the xml - the uglier option is to pass the servlet context object right down to the class that loads the resource - the other option is to use some kind of a static initializer to make the servletcontext object globally available
    hope this helps

  • Media Encoder CC specify file output location doesn't work?

    Hello everybody! When i render a video from Media Encoder CC the "specify output file location" only works if i go to preferences then select the folder,then when i reboot the PC it still says it's going to that location but doesn't. Does this happen to any one else? And how can i fix this? thanks !

    Check your permissions-settings. It sounds like your preference file is is written to a destination that has specific read-write permissions. Or that it is erased when rebooting (schools often have this implemented)

  • File Upload applet not opening in Query Mode

    File Upload Applet is opening in Query Mode in Siebel 7.5, where as in Siebel 7.8 its not opening in Query Mode.
    Should anything be changed in CFG? or siebel restricted this?

    Hi,
    There is a property called "Auto Query Mode" in the applet. Check whether this has been set to "New Query" in 7.5. If so the applet will be opening in Query Mode automatically. If this property is blank, in 7.8, the applet will not be opening in Query mode. Check and let me know.
    Regards,
    Joseph

  • Weird CS4 error when saving eps files on a Mac: "...specified files already exist in the target location"

    Hi There,
    All 3 workstations in our studio are experiencing weird file behavior when re-saving eps files from Illustrator.
    Basically Illustrator creates a new file in addition to the original and adds a "-01.eps" onto the file name. If you re-save your original, Illustrator brings up a dialogue box that states:
    Some of the specified files already exist in the target location. The files marked below will be replaced:
    filename.eps
    filename-01.eps
    We've been deleting the "-01.eps" files each time but it's becoming tedious. The behaviour occurs when re-saving an eps file to a server or the desktop.
    All machines are new Quad-core MacPros running:
    - Leopard 10.5.8
    - Illustrator CS4 14.0.0
    We've checked for Illustrator updates from within Illustrator but we seem to be running the latest version.
    Is anyone else experiencing this behavior?
    Any help or pointers in the right direction would be much appreciated.
    Cheers
    Ben

    Thanks for the reply.
    The error occurs when we save the document but if we choose save as, "Use Artboards" seems to be unchecked so not sure if this issue is related or not. Will re-save the document using save as then see if the issue persists.
    Why do we still use eps?
    Basically because we've found it to be much more compatible. Our entire logo library is in eps format (18 years worth) partly because it was previously the only format to use and partly because it allows account managers to send logos to clients, printers, TV stations etc and not involve the studio (saving out an eps version).
    Although "Create PDF compatible file" is a good idea, we've encountered costly issues with colours and images - especially if the recipient is using old CS software, non-Adobe software or is using some kind of hardware RIP. We now just go with what we know works.
    But I do find saving eps versions of everything to be a bit painful. In fact, I've always found Illustrator in general to be a bit painful when compared with Photoshop or AfterEffects. Illustrator seems like it's been developed by a different company some times!
    Cheers, and thanks for the help.

  • Java 7: Problems launching applets with jars on "file://" location

    Hi,
    We are experiencing a problem when updating our client's JRE from Java6 U 21 up to Java7 U 55.
    We have developed an Applet which is composed by several JAR files. Some of those JARs must be stored in local drive, and the JAR with the main Java class is stored on server.
    Let's supose we have a similar scenario like this:
    https://blahblahbah/bar.jar
    https://blahblahbah/test.html
    C:/foo.jar
    The code of test.html:
    <embed
      archive="file:///C:/foo.jar"
      cache_archive="bar.jar"
    />
    This code works fine on Java 6 and Applet is correctly loaded.
    However, with Java 7 a security exception is raised when trying to load JAR files from "file:///" location during Applet launch:
    java.lang.SecurityException: Permission denied: file:/C:/foo.jar
        at sun.plugin2.applet.Applet2Manager._loadJarFiles(Unknown Source)
    We have tried several tests using a java.policy file which grants all possible permisions:
    grant codeBase "file:/C:/foo.jar" {
        permission java.security.AllPermission;
    grant {
      permission java.security.AllPermission;
    We also tried to low Java's security level to "MEDIUM", with no success.
    We finally only managed to run the Applet if we explicity disable the "Next-Generation Plugin" with Internet Explorer 8. However, that's not a suitable solution, and still does not work with Mozilla family browsers.
    Eventhought with Mozilla browsers is still not working.
    Is there any restrictions in Java 7 that prevents to read jars from being loaded from local drive when launching Applets?
    Thanks in advance,

    Thank you baftos.
    I had read the whole message before posting mine. It's not the same problem. I'm able to run the sample signed applet always having the jar in the same location than the HTML page serving the applet via JNLP:
    <jar href="SignedAppletTest.jar" main="true"/>
    However, the security exception raises when trying to read that jar from local drive:
    <jar href="file://C:/SignedAppletTest.jar" main="true"/>
    ExitException[ 3]java.lang.SecurityException: Permission denied: file://C:/SignedAppletTest.jar
        at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
    I have even tried to decompile JNLP2Manager class, without seeing anything useful on that loadJarFiles method
    The only way I managed to avoid the problem is unchecking the New Generation Plugin and running the Applet with IE. Not a suitable solution for me at all..

  • HT1923 I get a message-error opening installationlog file. Verify that the specified lof file location exists and is writeable-when I try to uninstall iTunes and other components

    I get a message-error opening installationlog file. Verify that the specified lof file location exists and is writeable-when I try to uninstall iTunes and other components. How can I uninstall and reinstall iTunes?

    Hey jemerritt,
    Thanks for the question. I understand you are experiencing issues with iTunes for Windows. The following resources may help to resolve your issue:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Issues installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Thanks,
    Matt M.

  • Location to upload and share .SWF files?

    is there a location to upload .SWF files to share similar to what youtube does for videos?
    Thanks.

    Ah, that probably wont work out too well then, considering the community
    there has both high standards and a love of inside jokes.  If you have some
    kind of ftp site you can have them upload the files into that, and then go
    to the urls of the respective projects (for example"
    http://www.exampleftp.net/studentname/project1.html")
    That would probably be the best way to do it that way it keeps the students
    work in a closed network, getting feedback mainly from their peers, as well
    as filters out any kind of spam/offensive/generic "this sucks" type comments
    community based sites tend to run into a lot.  Also, the work they upload to
    the ftp site can be viewed from any computer.  Your best bet is probably to
    use Dreamweaver to set up the server and uploading their files.  That's how
    I did it when I took a class in Flash web design last semester.  Hope this
    helps, and I'm sure someone on the Adobe boards can help with setting up the
    FTP site, since it's still something I have all that much experience with.
    That or a tutorial could work too.

  • Multiple File Upload Applet

    I am attempting to code a JavaBean wrapped by an applet that will upload multiple files to a web server via the multipart/form-data mime-type.
    I have moved a number of files to the web server with limited success.
    I cannot move more than roughly 30Mbs of files in any configuration without causing a fatal exception.
    I am confident that it is a limitation of the client's VM and the memory allocated to the applet.
    I have seen several commercial grade applets that claim they can move any number of files even totalling 180Mbs.
    My applet is very simple. It opens a JFileChooser dialog box, allowing the user to select multiple files and communicates directly to a server side component that accepts multipart/form-data.
    I am navigating the protocol just fine. It seems to be a memory problem on the client side. Does anyone know how I can defeat this restriction and pass a reasonably high number of files (100-200) ranging from 50Mbs to 180+Mbs?
    Secondly, why does this happen: when I put my files onto the output stream, no files move accros the stream until I call .close(). How can I write the code to begin transferring bytes as soon as I call outputstream.write(xxx)?

    i am also developing multiple file upload applet and i transferred 1,4gb of data (2 files a 700MB) successfully.
    also, i just transferred a few hundred files with total size of 900mb to my localhost webserver (~5000kb/s)
    1) open file
    2) read a few kilobytes into buffer
    3) send them to the server
    4) flush the outputstream (!!)
    5) clear buffer and goto 2)
    6) if end-of-file, close the file and flush again.
    the outputstream is flushed every few kilobytes, so it will be sent over the socket to the server and not buffered until dawn.
    i don't know how the server-side is working, but i used apache/php script.
    you can try out my applet under
    http://www.haller-systemservice.net/jupload/

  • Upload Friendly (Multiple File Upload Applet)

    Title : Upload Friendly (Multiple File Upload Applet)
    Description : UploadFriendly is an easy to use Java Applet that will allow multiple file
    uploads on a web server in a web page. The control supports file filtering, limits and more.
    Samples available in the following languages: ASP, ASP.NET, PHP, Coldfusion and JSP
    Link: http://www.uploadfriendly.com/
    Type: Commercial (30 days Trial)

    Hi shiil,
    To move the documents between site collection, content organizer rules would be a recommended method, you can activate Content Organizer features to enable content organizer rules on the site, to root the document to another site collection.
    Also, for this issue, as Prasath suggested, you can check out the document in the ItemAdded event, then add ItemCheckedout event, in the ItemCheckedout event, delete the document. Or as content organizer rule does, you can create your own timer job to move
    the document.
    More information, Content Organizer Feature Overview for SharePoint Server 2010 Developers (ECM):
    http://msdn.microsoft.com/en-us/library/office/ee558288(v=office.14).aspx
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Specify a file location in web app structure?

    I wish to store several small properties in a file for my web app, but how to control where they go? for instance (used in a class called from a jsp):
    FileOutputStream out = new FileOutputStream("tempFile.prop");
    out.println("test out");
    out.close();where does tempFile.prop go? Right now it appears to go into the root directory of the web app, but I would like to be able to dump it into web-inf, or in some other folder in my application.
    How do I specify a relative file location in the web app structure?
    On most runs of the app, the file is stored in the root folder of my app (the context?)
    Can I code relative paths from there, and how do i gaurantee where the files will go?
    I have tried several different things, and most of the time the behavior is as reported, but on a number of occaisions, the files go into tomcat/bin. WHAT? WHY? anyway, if there are any tried and true rules on this, let me know.
    Thank you

    Check out the File class, which can check the directory and file's existance (and other properties). I would simply create servlet that checks/writes to a file in which you can actually specify the path to the file, whether absolute (c:\\..\\..\\kf.prop) or relative (using servlet context to get to the webapp folder and then to various directories below that).
    Good luck

  • How to upload file located on the network

    I used following API successfully upload file located on
    database machine. I
    got error when upload file located on network. I run this
    as "Portal30" user
    which has DBA priviledges.
    I used code like this.
    result:=wwsbr_api.add_item(p_caid=>53,
    p_folder_id =>4487,
    p_display_name => 'Test',
    p_type_id => wwsbr_api.ITEM_TYPE_FILE,
    p_type_caid => wwsbr_api.SHARED_OBJECTS,
    p_region_id =>5,
    -- these are not working
    p_file_filename=>'//nt2/vol2/common/test.pdf'
    p_file_filename=>'///nt2/vol2/common/test.pdf'
    p_file_filename=>'S:/common/test.pdf'
    -- this works
    p_file_filename=>'c:/test.pdf'
    Errors:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NullPointer Exception
    ORA-06512: at "PORTAL30.WWSBR_API",line 24
    ORA-06512: at "PORTAL30.WWSBR_API",line 277
    PS: we tries run Oracle as a privileged user other than System
    user. it won't help. Am I missing something here. I am new on
    the network problem. How I can verify the privileged user access
    the network.
    we have portal 3.0.9.8.1 running on Windows 2000

    Thanks for the direction. I can upload same file through Oracle
    Portal "Add Item" user Interface. So I assume file is visible to
    the database. Notice the Portal uses wwv_additem.additem and
    wwv_add_wizard.edititem to upload file. Do they eventually use
    wwsbr_api.add_item and wwsbr_api.add_item_post_upload? What is
    syntax of reference file on remote drive?
    Thanks
    Linda

  • Excel file located in application server to be uploaded

    Hello friends,
                 Please tell me what are the steps to be followed while uploading the data from a file in EXCEL format located in application server in to SAP data base using BDC.
    Thanks in advance,
    Ram.

    declarations:
    DATA:IT_EXCEL LIKE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
    I guess u r familiar with notepad upload.....just use your declaration as it is. Below is a basic demonstration of uploading data from excel...reward if useful.
    Excel file Locating.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
    PARAMETERS: P_FILE TYPE LOCALFILE OBLIGATORY .
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          STATIC    = 'X'
        CHANGING
          FILE_NAME = P_FILE.
    Check whether the uploaded fiel is excel or not
    AT SELECTION-SCREEN ON P_FILE.
      WK_LEN = P_FILE.
      CONDENSE WK_LEN NO-GAPS.
      LENT = STRLEN( WK_LEN ).
      WK_ALP = LENT - 4.
      B = WK_LEN+WK_ALP(LENT).
      IF ( B NE '.xls' AND B NE '.XLS' ).
        MESSAGE E939.
        CLEAR P_FILE.
        STOP.
      ENDIF.
    START-OF-SELECTION.
    do all the othre process here
    PERFORM FETCH_FROM_FLAT_FILE.
    store the values to your normal itab and the process.
    LOOP AT IT_EXCEL.
        CASE IT_EXCEL-COL.
          WHEN '0001'.
            MOVE: IT_EXCEL-VALUE TO RECORD1-MATNR_005.
          WHEN '0002'.
            MOVE: IT_EXCEL-VALUE TO WK_WERKS.
          WHEN '0003'.
            MOVE: IT_EXCEL-VALUE TO RECORD1-BUDAT_002.
          WHEN '0004'.
            MOVE: IT_EXCEL-VALUE TO RECORD1-BKTXT_004.
          WHEN '0005'.
            MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_007.
          WHEN '0006'.
            MOVE: IT_EXCEL-VALUE TO RECORD1-ERFMG_008.
        ENDCASE.
        AT END OF ROW.
          APPEND RECORD1.
          CLEAR RECORD1.
        ENDAT.
      ENDLOOP.
    **Here record1 is the internal table holding the data fetched from excel
    end-of-selection.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME                = P_FILE
          I_BEGIN_COL             = 1 "From 1st Column
          I_BEGIN_ROW             = 2 "From 2nd row
          I_END_COL               = 6 "Till 6th Column
          I_END_ROW               = 65536 "Till Row
        TABLES
          INTERN                  = IT_EXCEL
        EXCEPTIONS
          INCONSISTENT_PARAMETERS = 1
          UPLOAD_OLE              = 2
          OTHERS                  = 3.
      CLEAR IT_EXCEL.
      DESCRIBE TABLE IT_EXCEL.
      IF SY-TFILL = 0.
        MESSAGE I937.
        STOP.
      ENDIF.

Maybe you are looking for