Figure out the output path in tomcat

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
How to get the path of current directory?
try
     PrintWriter out = new PrintWriter(new FileWriter("hello.txt"));
     out.println("HELLO");
     out.close();
catch(IOException e)
any ideas?? Thanks!!

import java.io.*;
try this way
public class Filer{
public static void main(String []args)
try
String PATH="C:/MyPath/Myfolder/";
PrintWriter out = new PrintWriter(new FileWriter(PATH+"hello.txt"));
out.println("HELLO");
out.close();
catch(IOException e)
Hope this solves your problem
}

Similar Messages

  • How to get the output path in Java?

    Hi all,
    is there a way (method) to get the output path (where compiled classes are put) in Java?
    thx a lot!
    Michele

    If you have already successfully loaded the classes into memory, and you want to find out where the classes are physically stored, then you can use Class.getResource() to retrieve the location of the file.
    import java.net.URL;
    public class Find
      private void run(String obj) {
        try {             
          Class cls = Class.forName(obj);
          //Here is the change to input correct resource path
          //instead of class name 
          String resourcePath = "/"+obj.replace('.','/')+".class";
          URL url = cls.getResource(resourcePath);
          System.out.println(url);
        catch (Exception e) {
          e.printStackTrace();
      public static void main(String[] args) {
        Find find = new Find();
        find.run(args[0]);   
    }java Find java.lang.String
    jar:file:/usr/local/j2sdk1.4.2_13/jre/lib/rt.jar!/java/lang/String.class
    Edited by: Jin on Oct 23, 2007 10:38 AM

  • Unable to figure out the classnotfoundException

    Dear Members,
    I have an applet on which I want to show images. I have put .class and .html in the same directory and the images in the images directory.
    I'm usong Tomcat 5.5.4.
    Note: I have created certificates and also policy files for the applet.
    When I run the same code using eclipse, the code is working fine.
    And when I try to run in the browser its throwing the following Exceptions.
    java.lang.NoClassDefFoundError: AdminApplet1$1
         at AdminApplet1.init(AdminApplet1.java:74)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source) Where AdminApplet1 is my applet.
    Following is the code written in the .html
    <applet codebase="http://localhost:8080/project/"
            code="AdminApplet1"
            archive="SAdminApplet1.jar"
            height=400
            width=600 >
    </applet>where SAdminApplet1.jar is signed jar.
    I'm trying to figure out the problem since last 2 days. If you want more details about the problem please let me know.
    I have referred http://java.sun.com/developer/technicalArticles/Security/Signed/
    for creating the certificates
    If you think I've gone wrong while creating the certificate then please show me a way.
    I'm looking forward for the helping hands.
    Thanks.

    Please put all the class files in the jar.
    Considor this example:
    import java.applet.*;
    public class test extends Applet {
         public void start() {
              System.out.println("this is start");
              try{
                   System.out.println(System.getProperty("java.version"));
                   (new subTest()).printSomething();
              }catch(Exception e){
                   e.printStackTrace();
         public void init(){
              System.out.println("this is init");
         class subTest{
              void printSomething(){
                   System.out.println("something");
    }compiling with javac test.java gives me:
    test.class
    test$subTest.class
    When I remove test$subTest.class and open the applet with a html page I get:
    java.lang.NoClassDefFoundError: test$subTest
    (looks familiar?)

  • Sun ONE Studio 4 aka Forte: How to set the output path for classes ?

    Help !
    Beginner's question:
    Sun ONE Studio 4 aka Forte:
    How to set the output path for classes ?
    As default, the class files are created in the same directory as the
    sources.
    In opposite, both JBuilder and Together support that there is a tree
    with the sources and another tree with the classes.
    The first answer I got was "not possible with Forte, but just if you write your own "ANT Build script" !
    a) Please point me to a ready-to-use ANT script for this purpose, if such is available
    b) Is using ANT instead of the MAKE as comfortable ? Besides the separation of sourcecode and classes, I would like to keep everything else to be the same, i.e. I don�t want to edit the ANT file if I enlarge the project by directories or files.
    Tia
    Sincerely
    Rolf

    You can set S1S's options to place newly created .class files in a specific location.
    Identify the compiler that is being used - Open the S1S's Tools/Options window, expand Editing and select Java Sources. Note the Default Compiler value. (If it's one if the Ant options, you use Ant to specify this option, not S1S.)
    Open the S1S's Tools/Options window, expand Building/Compiler Types and select the appropriate compiler.
    The Properties tab of the compiler has the property Target, which sets the filesystem where the compiler output is directed. If you choose <not set>, the .class files are written to their source directory.
    When you set the Target, your change affects all classes that use this compiler.
    Very few options can't be set in S1S; the challenge is finding out where they're set!

  • Help! I figured out the problem - sort of.

    So I posted my problem two days ago. I found that only some of my pages were loading in Firefox 3. I didn't know why (see below for original posting).
    With a little experimenting, I have found that republishing the pages that "work" actually causes them to no longer work. I'm pretty sure I published these pages that worked with previous versions of iWeb. Now that I'm using the latest version of iWeb, any new pages (blogs) cannot be viewed by Firefox 3.
    Is there anyone out there with a work around? Solution? Anyone?
    HERE IS THE ORIGINAL POST:
    HELP- Take a look at my pages- What's wrong?
    Posted: Nov 19, 2008 3:19 PM
    Reply Email
    Here are links to my pages: the first link doesn't load in Firefox 3. The second link loads fine. I can't figure out the difference between the two pages. Any web gurus out there that can determine my problem? I really want people using firefox to be able to view my site.
    THANKS!!
    LINK 1:
    http://web.me.com/reeldamian/DAMIANDP.COMNYO/COMMERCIAL_REEL/COMMERCIALREEL.html
    LINK 2:
    http://web.me.com/reeldamian/DAMIANDP.COM_NYO/FX/FX.html
    Message was edited by: 3pointer

    I installed oracle apps 11.5.10.2 using steps given in thread and I didnt have any problems. I then installed it on my friends laptop and it worked fine. but recenly it stopped working in my laptop, i was not able to open login page from main url (http://www.msb.ora:8000) it gave error : page cannot be found
    So i reinstalled it on fresh system again.. but since then it not working. I have tried atleast 9-10 times and everytime it ends up with same error "jsp is not responding", I am able to open the rapid install main page but I am not able to open login page. it says page cannot be found. i followed all the steps suggested by you guys in this thread to solve this error, but still have no luck.
    I have tried following steps to solve the issue
    1) As its recommended to installed apps on fressh os without jdk i did the same, as i didnt worked i tried installation with jdk preinstalled,
    2) i have tried on both windows server 2003 and win xp professional
    3) I tried to change the jdk path in jser.properties file
    I will really appriciate any help to solve this problem. Below is system details:
    os: windows server 2003
    ram : 1gb
    processor: 1.83ghz core 2 duo
    Oracle apps 11.5.10.2
    java version: 1.4.2_04 ( installed by rapidwiz)

  • I need help figuring out the best way to convert analogue video to DV so that I can edit it.

    I have a large number of VHS and hi8 tapes that I want to convert to high quality DV.
    I have a couple of options. One is an Elgado Video capture system.
    The other is a Sony Digital Media Converter Box (DVMC-DA2).
    I have tried a few of the less important tapes using the Elgado Video Capture system. It only allows you to convert to MPEG4 or H.268. It is not very good quality, especially for archival items or items I would later wish to edit.
    I also have the Sony Digital Media Converter Box. I have heard that this is a superior option. So far, though, I have only been able to figure out how to import using an old version of iMovie HD. This makes a large imovie project file (approximately 6.18GB for a 28:30 clip vs a 348.9MB for an MPEG4 using delgado.
    On top of that to convert the file from an iMovieProject file to DV is an additional step that so far looks like will take a half an hour at best.
    Is there any way for me to import VHS/hi8 tapes using the Digital Media Converter Box to creat high quality DV files directly? If so, where can I find this info? What steps should I take and what are the settings I should use.
    I have a lot of tapes so I want to figure out the right and most efficient way to do this because I will be repeating it a bunch of times and would hate to have to start over again.
    I should also mention that I am using a Mid 2010 MacBook Pro, with OSX 10.9.1
    I'm sorry in advance if this seems like an obvious question, but I have been googling and looking at tutorials on the site and just have not found the answer. There are a lot of ads for expensive low quality services to do this converting for you, so maybe the answer I am looking for is burried in all that advertising.
    Thanks

    Thanks Biggles and Gotz. I just couldint find capture, but now I can! (It was right under my nose too).
    I'm trying it now and it appears to be working. Do you have any other recommendations for capturing from hi8 video source as far as setting go? I am using DV to capture. Are there any other settings I should pay attention to?
    There is an extra line of video noise at the bottom, but when I google it, it sounds like it won't show on most standard tvs and if I want to fix it for online, that I should mask it after the fact vs scaling up the video.

  • Is there a way to figure out the name behind an Apple ID?

    Is there a way to figure out the name behind an Apple ID?  My oganization uses an iPad as a kiosk.  Somone accessed the iPad, changed the Apple ID associated with iTunes, downloaded a game and set a password to lock up the whole iPad.  We had to completely restore the iPad in order to access it.  When I tried to upload a new app, a different Apple ID popped up, and I'm assuming it was the person who locked the iPad and downloaded the game.  I would like to figure out who owns that account, just so we can not allow that person access to the iPads anymore.
    Is there a way to do this?

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Perhaps with a court order because the person committed a criminal act. Otherwise it is doubtful that Apple would violate the privacy of a client/account holder just on your word.

  • How do I find out the exact path of each and every file that LabVIEW finds and loads into memory for a given top level vi?

    How do I find out the exact path of each and every file that LabVIEW finds and loads into memory for a given top level vi? There is probably a trivial, easy way to get this info, but I have not yet found it!  Thanks..

    Or if you want to grab all the paths programatically, try the attached VI.
    Open the top level that you want all the paths from and close all others, then open the
    attached and run it. It will return an array of all the VIs that the VI
    in question uses, including vi.lib VIs. You can filter these as well if
    you like.
    Ed
    Message Edited by Ed Dickens on 08-01-2005 07:01 PM
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
    Attachments:
    Get all paths.vi ‏29 KB

  • Is there a way to dynamically figure out the FIRSTROW & LASTROW using Bulk Insert?

    I noticed most of my files follow a certain convention, so I can use Bulk Insert with this:
    FIRSTROW = 2, LASTROW = 224
    However a few files have many more records.  I'd like SQL Server to dynamically figure out the first and last rows with data, but I don't know if that's possible.  Can someone confirm?
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Nope, you would need read the files from some program. Could be a CLR stored procedure if you want to do it from SQL Server. But from BULK INSERT alone, no.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I am moving from Southern California to Maui, Hawaii and I need to figure out the best way to get my 24 inch iMac across the ocean. Does anyone know the best way to do this?

    I am moving from Southern California to Maui, Hawaii and I need to figure out the best way to get my 24 inch iMac across the ocean. Does anyone know the best way to do this? I have found GearGrip's LCD harness so that I can do carry-on onto the plane...  Or maybe use a Pelican Case to do it as a "checked bag"? Or any other suggestions??! Please help!
    Thanks so much!!

    I don't recommend you send the iMac in a checked bag. Might get damaged.
    Check the airlines website for carry on guidelines.
    Or, if you have the original box that the iMac came in, if you have someone who can pick up the iMac for you, send it ahead Fed Ex and insure the package.
    Just make sure the display is covered to protect it. A blanket perhaps.
    Aloha ...

  • How can i figure out the answers to my security questions if i forgot the answers

    how can i figure out the answers to my security questions if i forgot the answers

    Welcome to the Apple Community.
    Start here, and reset your password, you will receive an email with your new password, then go tomanage your account > Password and Security and change your security questions.
    If that doesn't help you might try contacting Apple through iTunes Store Support

  • My iphone got stolen. how do i figure out the emei number?

    my iphone got stolen. how do i figure out the emei number?

    Here is what you should do:
    http://support.apple.com/kb/HT5668
    And here is how to report the theft:
    http://support.apple.com/kb/HT2526

  • My MacBook pro mid 2012 doesn't seem to have a "save as" function, so I can't seem to save multiple page pdf's together after moving thumbnails into the sidebar. It only saves the first page. I can't figure out the rename function either. Help?

    My MacBook pro mid 2012 doesn't seem to have a "save as" function, so I can't seem to save multiple page pdf's together after moving thumbnails into the sidebar. It only saves the first page.
    I do have a 2008 version of Microsoft Office installed to save money, but that shouldn't affect things. I can't figure out the "rename" function either. Help?

    Oh, and I also reset my NVRAM, my computer hasn't frozen again yet, so I'm not sure if it has made a difference.

  • HT204053 Help me figure out the restrictions passcode

    Help me figure out the restrictions passcode i need to get on to restrictions

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device
    1. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. iOS- Understanding passcodes
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. How to Recover Forgotten iPhone Restrictions Passcode | The iPhone and iPad
    6. Restoring iPod touch after forgotten passcode
    7. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    Restrictions Passcode Help
    1. How to Recover Forgotten iPhone, iPad Restrictions Passcode

  • I Ipod class wont play TED and other video podcasts.  The genious bar could not figure out the problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.

    My Ipod classic wont play TED, The Grid, Techzilla and other video podcasts (but not all video podcasts).  The genious bar could not figure out the problem. Instead, the Apple store gave me credit towards a new classic, which produced the same problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.  Lastly, I tried restoring the ipod to no avail.  I've heard this is a video codec problem. 

    See this extensive older thread on the issue.
    https://discussions.apple.com/thread/2813428?start=45&tstart=0
    B-rock

Maybe you are looking for

  • A forgotten password need help asap

    I forgot my hp mini 100 password that you use when you turn the laptop on. It says "fatal error... System halted. CNU9075DKL please asap!

  • Tasklist ERROR: Not Found

    Hey all, So I have a Windows 2008 server (32 Bit) and I'm trying to run Tasklist from the command prompt.  When I do so, I recieve the "ERROR: Not Found" error.  If I run it with the "?" flag then I do get the help file.  I have done some searching b

  • How can I arrange the components in a better layout?

    Hi, I found that the layout manager is not enough for me to put things around, there's only some straight position like east, south, southeast, etc. Is there anyway I can put the component in a particular point? Thx. Adrian

  • S_TABU_DIS and &NC&

    Hello, We have some users with u2018&NC& authorization group and 01/02 activity value with SE16 and S_TABU_DIS authorization object.  The auditors have mentioned this is a security risk because they may have access to update more tables than they nee

  • No dashboard access after Firmware Release 1.05.36

    I purchased the EX4 about a week and a half ago. Hooked it up and all went fine. From dashboard I did firmware updates. First two went fine as I was able to get back in via dashboard. Then I did the FR 1.05.36 (the one that has you unplug) When it ca