Current Directory ? How?

I finally got the applet sign and got the certification to work... thanks to ncoleman1.
As my java code consists of :-
ip = new FileReader("clue.txt");
run together with a java.policy stored in c:\windows and certification ask for permission to grant/deny but consists of error message java.io.FileNotFoundException:clue.txt (The system cannot find the file specified)
But
ip = new FileReader("c:\\windows\\desktop\\test\\clue.txt");
the applet can run and display the data in clue.txt on the screen and I think it bypass the certification as it didn't ask for permission to grant / deny as I always select "grant this session only".
I just want the applets to run and look the file in the current directory where the html is stored. As I always stored all files in one directory.
Can help?

The directory where the HTML is stored? That would be on the same server where the applet was loaded from, would it not? In other words, on some other machine. If you want to get clue.txt from that directory, you must get it from the server via HTTP.

Similar Messages

  • How to create a file in current directory

    hi,
    I want to create a file in a current directory, But when i written following
    code then it cannot create file, How i will create file in current directory?
    Is there anyone who can help me?what will be the solution of this problem?
    Please give me solution
    String dir=application.getRealPath("/");
         int count;
         String filename="sample.txt";
         out.println(dir+filename);
         FileOutputStream fout=new FileOutputStream(filename);
         PrintStream p;
         p=new PrintStream(fout);
         p.print("1");
         p.close();with regards
    Bina

    hi,
    my problem is that my path is ok...but when i open file in this directory then
    it cannot open a file, is there anyone who can do it? When a user save data in server from remote
    area then what will be path of my code? how i will solve it? please give me
    solution.
    with regards
    bina

  • How to create a file in server's current directory

    hi,
    I have a project, but when i will run my program on internet Explorer then
    it will create a folder in server's current directory, but i will not specify
    drive & folder, it will create a folder in server's current directory, after that
    i will read file from that, what will be the solution of this ? Is there
    anyone who can give me solution? PLease help me
    With regards
    Nahar

    ServletContext context = session.getServletContext();
    String realContextPath = context.getRealPath(request.getContextPath());this will give you access to the servlets current directory
    from there you can create a file
    I dont know how much this will help

  • How can i specify current directory path of wsusscn2.cab

    SCRIPT:
    How can i set current directory file path of wsusscn2.cab where i placed this vbscript, instead of going to c:\wsusscn2.cab.
    =======================================================================
    Dim fso
    Set wshNetwork = CreateObject("WScript.Network")
    strUser = wshNetwork.Username
    Set fso = WScript.CreateObject("Scripting.Filesystemobject")
    Set f = fso.CreateTextFile(".\Missing Patch Details\" & wshNetwork.ComputerName & "_missing_patches.csv", 2)
    Set UpdateSession = CreateObject("Microsoft.Update.Session")
    Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
    Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "c:\wsusscn2.cab")
    Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
    WScript.Echo "Searching for updates..." & vbCRLF
    UpdateSearcher.ServerSelection = 3 ' ssOthers
    UpdateSearcher.ServiceID = UpdateService.ServiceID
    Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
    Set Updates = SearchResult.Updates
    If searchResult.Updates.Count = 0 Then
        WScript.Echo "There are no applicable updates."
        WScript.Quit
    End If
    WScript.Echo "List of applicable items on the machine when using wssuscan.cab:" & vbCRLF
    For I = 0 to searchResult.Updates.Count-1
        Set update = searchResult.Updates.Item(I)
    f.WriteLine update.Title
    'WScript.Echo I + 1 & "> " & update.Title
    Next
    WScript.Quit
    ==========================================================================
    prakash

    Just remove the c:\ and it will be looked for in the current directory.
    If you want the script how get the script path and remove the file name or use the shell
    currentFolder = CreateObject("WScript.Shell").CurrentDirectory
    ¯\_(ツ)_/¯

  • How to get the Current Directory

    Hi,
    I need to tell the system to read a file in my current directory. How do I tell the system what the current Directory Path is
    Thankx in advance...

    It depends on the current working directory from which you start your JVM.
    From DOS or UNIX shell this is the directory where you have come by "cd".
    On Windows you can do the same from Explorer or other file managers: the directory where you are when starting JVM.exe.
    If you define shortcuts - e.g. on the desktop -, you specify it there as the "working directory".
    You can retrieve this directory by
    System.getProperty( "user.dir" )
    Now with File classes:
    Each file name without path will be interpreted as being in this directory.
    Absolute paths are clear.
    But you can't mix this:
    If you specify "test/debug.ini" or "test\\debug.ini" from debug directory: false!
    If you specify "../debug.ini" or "..\\debug.ini" from debug/test directory: false!
    Do it this way:
    Start from debug directory.
    So you can access file debug/test/debug.ini as
    System.getProperty( "user.dir" ) + "/test/debug.ini"
    Works?

  • How to now the Current Directory

    Hi everyone, i have a little problem, i dont'n know how to get the name of the current directory where i have the .jar file of my applet, and i need to know which is this directory to do something on it.
    How could i know the current directory?...
    Thanks.

    Hi.
    You can not get the current directory: applets can not access the hard drive. Instead you can get the code location, which will given the current directory if running locally.
    Try this: within the applet do : getCodeBase(). This will give you an URL to the code of the Applet, that is the JAR file.
    Hope this helps,
    Nuno

  • How can make JFileChooser set current directory to a nethood "\\host"?

    hello everyone,
    I want to set the JFileChooser's current directory to a nethood named "host".
    In the windows file dialog we can type "\\host\n" and we can explore the remote file system if which has sharing items.
    I try to use setCurrentDirectory(new File("\\\\host")), JFileChooser does't work. I must step by step explore the host in networkplaces.
    Set the host's subdirectory such as "\\\\host\\f1"can work but how can i get a remote host's subdirectory?
    thanks for any help.
    hu.

    Valerie Debonair wrote:
    1. Is there any easy way to set a an environment variable changing a working directory where a script is being executed? I 'm not so sure if i understood you exactly.
    Script can be executed/called only in/at the directory where it is. You can call script from path 'a' even if script's location is in the path 'b' , but you can't execute script with something like $@/dir1/dir2/myscript.sql if the script is realy in /dir1/myscript.sql .
    Although for something similiar you can consider using symbolic links if you are on unix/linux.
    Environment variables can't be changed and defined from within sqlplus so you will have to define them when you are in the os's command line or related gui where you can do the same. Also you could create env variable that can hold the path to the script so when the script is called , there is no need to write the full path, only variable name.
    2. How can I view path environment?path environment.
    There is no such thing.
    There is path environment VARIABLE . You can view it's contnent by typing echo $path in linux/unix or by typing set path in windows.
    regards,
    Valeriecheers

  • How to trace an application which is not in the current directory?

    Hi,
    When I use simple example 'Trace' to trace my application in current directory, it works well.
    But I cannot trace the applications which are in different directory or in an .jar file. Even I've already add it to the classpath.
    The following is my test:
    I put Myapp.class in .\classes
    java -cp .;.\classes com.sun.tools.example.trace.Trace Myappit shows me:
    java.lang.NoClassDefFoundError: Myapp
    Warning: classic VM not supported; client VM will be used
    Exception in thread "main" -- VM Started --
    -- The application exited --Can anyone help me ?
    thanks

    The following is my test:
    I put Myapp.class in .\classes
    java -cp .;.\classescom.sun.tools.example.trace.Trace MyappThere are two JVMs involved when you are tracing or debugging.
    Rather than putting the classpath on your command line, set it as
    an environment variable so that both JVMs can use it. That way, the
    second JVM (which is executing the Myapp class) will be able to find it.
    If your current directory is %JAVA_HOME%/demp/jpda, then this example
    will trace the SwingSet2 demo program:
    set CLASSPATH=".;%JAVA_HOME%/lib/tools.jar;%JAVA_HOME%/demo/jfc/SwingSet2/SwingSet2.jar"
    java com.sun.tools.example.trace.Trace SwingSet2Let me deconstruct the CLASSPATH:
    . is on the classpath so the first JVM will locate
    the com.sun.tools.example.trace.Trace class relative to
    your current directory. You may also use the absolute
    path instead of dot.
    %JAVA_HOME%/lib/tools.jar is there so both JVMs
    can locate the JDI (Java Debug Interface) classes in tools.jar.
    %JAVA_HOME%/demo/jfc/SwingSet2/SwingSet2.jar is
    there so the second JVM (the debugee) can load the
    SwingSet2 class..

  • How can I make an applet look to the current directory to read a txt file in?

    I am using a File class passing only the file name as the contructor but forte still looks in "C:\forte_jdk\forte4j\bin\Events.txt" which is not my current directory for the project.
    If leave it and ftp this applet to my web site I get an IOException.

    I always find visual aids helpful. See below for screenshots & discriptions.
    01. The Basics
    When you create a new site & go into design view (in the example below it's the Home page), you'll see the following.
    The white box is your page.
    The grey box outside of that is your browser area.
    The black & white checkered area is the Adobe Muse CC application chrome.
    02. Add Box
    Draw / Add your rectangle or text frame (text tool). I drew a rectangle, gave it a fill color of blue & turned the stroke from 1 to 0.
    03. Extend & Snap to Browser Edge (Left)
    Click, hold  and drag your mouse on the center adorner (adorner is the little squares that you can grab to resize your rectangle) until you resize your rectangle to the browser edge (the dark grey area) until you see a red line. This means you've 'snapped' one of the rectangle's edge to the browser edge.
    04. Extend & Snap to Browser Edge (Right)
    Repeat the process except do this for the right edge. In truth, it doesn't matter in which order you resize your rectangle to snap to the browser edges. The key thing is to be sure to do this for both sides of the rectangle & snap it to the browser edge (see the red line).
    05. You're done! Preview.
    06. Bonus!
    Once again, you can make rectangles or text frames 100% width, BUT you can't do this with placed images.
    However, you can do this with a rectangle or text frame. Then set the Fill of either the rectangle & text frame to be an Image & set the Fitting to 'Scale to Fill.'
    (see below for example - I used a rectangle & changed it's Fill property)
    Now when I preview, the image is 100% width. In truth, it's a 100% width rectangle with a fill of an image.

  • How to get the path of current directory?

    I have the Java servlet to produce text file, and it produces to C:\hello.txt,
    but I want to output in the current directory as the Java File:
    i.e. C:\jakarta-tomcat-4.1.30\webapps\ExtendedGUI\WEB-INF\classes
    try
         PrintWriter out = new PrintWriter(new FileWriter("hello.txt"));
         out.println("HELLO");
         out.close();
    catch(IOException e)
    any ideas?? Thanks!!

    The current directory is defined as the directory that you started your servlet container from. In your case, it was c:\. If you want it to fall into the same directory as your class files, I would start by finding out what TOMCAT_HOME or whatever container you're using is and adding to the directory until you get to your class directory. Make sense?
    The easiest way is to read the output directory from a properties file as a resource or a hardcoded path.
    HTH

  • How to get absolute path of current directory?

    Hi, everyone!
    I want to get the absolute path of current directory.
    Are there some APIs that I can use?
    Thanks in advance,
    George

    Hi, dheeraj_tak buddie!
    What do you mean in your reply?
    "in File class u have all this methods for getting absolute path "regards,
    George

  • How to read files from current directory for applet

    I have an applet that needs to read some audio files located in its current directory on the server and I just can't seem to figure it out...maybe I am being dumb...any help?

    You can use the ListSorter File Adapter Configuration property to sort based on timestamp. Basically add the following property to the inbound JCA file:
    <property name="ListSorter"
    value="oracle.tip.adapter.file.inbound.listing.TimestampSorterAscending"/>
    <property name="SingleThreadModel" value="true"/>
    More info see section 4.2.6 in http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm

  • How to know the current directory

    Could somebody write me an example to print the current directory I'm working on.
    e.g.
    java A
    d:\My Documents\source\A.java
    Thank you.

    Could somebody write me an example to print the
    current directory I'm working on.
    e.g.
    java A
    d:\My Documents\source\A.java1. This is not a directory
    2. A.class will be run, not A.java
    3. You'Ll never know where your sourcecode is
    4. Where your program thinks it is can be determined using
    new File(".")

  • Running a java program in a directory other than the current directory

    How do I run a java program that's located in a directory other than the current directory?
    There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
    javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
    But when I try to run it with:
    java -classpath /dir1/subdir1 /dir1/subdir1/Test
    I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
    Any thoughts?

    You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test

  • Getting current directory from an applet

    Hi. How can I get the current directory of my applet running on web without having to worry about permissin. I used the one below:
    curDir = System.getProperty("user.dir");
    but I get this error:
    ava.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
    any substiture for this? Thanks.

    You should be using URLs or similar approaches, and avoiding File, which will
    never work with an ordinary applet.
    InputStream in = this.getClass().getResourceAsStream("file.txt");That assumes the txt file is in the same place as the current classes .class file.
    For example, the same folder or that they are jarred in the same "folder" in the jar.
    You can also use a URL directly:
    URL url = ...
    InputStream in = url.openStream();and you can construct that URL with the help of Applet methods getDocumentBase or getCodeBase:
    URL url = new URL(this.getDocumentBase(), "file.txt");That assumes the txt file is in the same folder as the html file in which the applet is embedded.

Maybe you are looking for