Get the relative path for java class

How to get Relative path for java class which is inside in web-inf directory in webapps

ajay.manchu wrote:
Hi gimbal2,
My Requirement is i need to run a java class from batch file,when i created batch file in that i need to mention the complete path of the java class,so instead of mentioning that i want to provide only java class name,thats why i asked that one..
can u help me regarding that....
Thanks in advanceI wonder how that would work then. Let's take a fictive example. You have a class com.mycompany.myapp.Foo. This would mean that the class is stored in some directory like this:
c:/webrootdir/myapp/WEB-INF/classes/com/mycompany/myapp/Foo.classTo be able to run such a class from the commandline using Java, you would have to invoke this command:
java -cp c:/webrootdir/myapp/WEB-INF/classes com.mycompany.myapp.FooHow would knowing the exact path to this class help you?

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

  • Where can I get the source code for sun classes?

    Hello,
    When ever you download sun's j2sdk, the archive always contains the source code for the entire sdk in a zip file called src.zip except the sun.xxx classes like sun.awt.print.PrintDialog or sun.awt.font.FontResolver.
    For debugging purposes I need, if availabe, the source code of these classes which are not present in the src.zip.
    Please can someone tell me if theses classes are available as source and can point me where I can find it cause I am searching for it but can't find it on the net.
    Thank you
    Carolin

    Hey ChuckBing
    And your way is the only way, right? No.What on earth is eating you? Highly sensitive today?
    Where is the problem? There are two solutions of the question.
    The one link I posted points directly to the sun source download link. The "readme" explains, yippie, the sun sources are contained. Easy, isn't it?
    With the other one, you have to navigate at least through two other pages before you might find the link and only if you recognize that "Download JDK 5.0 source via SCSL/JRL" means the sun source code and not the sources contained in the JDK download. This is what I thought as I've seen this link the first time. Unfortunately there is no "readme".
    I prefer the easy way, I dont want to earn a doctorate. Ok, you can say dont "play the woman", but I'm a woman and a blonde too;-)
    But, let us stop the idle discussion here, please!
    Nevertheless, thanks to you and [email protected] for answering.

  • How to get the application path?

    Does some body know how to get the application path in Java? Here is an example about what I'm thinking: Let's imagin the application is on "c:\try" or "c:\ProgramFiles\MyApp". My question is how can I find the path where the application is. Please give an example if you know the answer. Thank you so much.

    Those two replies give you some useful directories, it's true, but maybe not what the OP asked. However the OP asked for something that doesn't have a meaning (applications don't have to be "on" any directory, whatever that might mean).
    Would the OP like to describe what the actual problem is here?

  • For weeks I have been viewing a doggy day care via their web cam.  This weekend I upgraded to Lion and have been unable to view the center since.  I get an error message for java webcam class not found.  All of my software is up to date--suggestions?

    For weeks I have been viewing a doggy day care center via their web cam.  This weekend I upgraded to Lion and have been unable to view the center.  I get an error message for Java plug-in 1.6.0_29 ....webcam class not found.  Any suggestions on how to fix this?

    Sorry, don't know what else to suggest unless there's a URL to the problem stream that someone here can try. Otherwise we can't test it to try and determine what might be wrong.
    BTW, make sure they're testing it with a Mac, not with a Windows system. If they test only with Windows, what they say is or is not working doesn't mean much.
    Regards.

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • 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!

  • Problem for getting the real path using one servlet and one jsp page

    I have one tomcat machine and several virtual domains. Eahc virtual domain has one realpath in the disc.
    I am using one servlet and one jsp page for using this servlet.
    my purpose is to load, using the servlet , the real path for the domains (eahc domain has its path).
    for this i make this:
    the servlet code is this:
    package utils.ticker;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class Edicion extends HttpServlet{
    public Edicion() {
    public String cc(){
    ServletContext myContext= getServletContext();
    String abspath = myContext.getRealPath("/");
    //here i want to return the real path
    return abspath;
    public static void main(String args[]){
    and the jsp page is:
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%
    tick.cc();
    %>
    </body></head></html>
    But this produces one error, NullPointerException and dont shows me the real path.
    Can anyone help me?
    thanks

    i have put this into one sevlet:
    package utils.ticker;
    import javax.servlet.ServletContext;
    public class Edicion{
    private ServletContext myContext;
    public Edicion(ServletContext myContext) {
    this.myContext = myContext;
    public String getCC(){
    return myContext.getRealPath("/");
    and in the jsp page this:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%=tick.getCC()%>
    </body></head></html>
    but appear this error in the tomcat.
    Can you, please, help me. i am trying to solve this during one week and i am desesperate.
    Thanks.
    ERROR:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    javax.servlet.ServletException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
         at org.apache.jsp.pruebas_jsp._jspService(pruebas_jsp.java:72)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    Apache Tomcat/4.1.18

  • Function module to get the file path in the system for TEMP folder

    Hi All,
    Is there any function module that I can use to get the file path in the system for TEMP folder.
    I mean, i am supposed to give only TEMP as the input for that function module and I need to get the path of that in the system as the output.
    I am unsing 4.0 version.
    Please advice.
    Regards
    Ramesh

    In Higher versions, we can use the below code:
    call method CL_GUI_FRONTEND_SERVICES=>ENVIRONMENT_GET_VARIABLE
        exporting
          VARIABLE   = 'TEMP'
        importing
          VALUE      = LV_TMP
        exceptions
          CNTL_ERROR = 1
          others     = 2.
      if SY-SUBRC <> 0.
        message id SY-MSGID type SY-MSGTY number SY-MSGNO
        with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      call method CL_GUI_CFW=>FLUSH
        exceptions
          CNTL_SYSTEM_ERROR = 1
          CNTL_ERROR        = 2
          others            = 3.
      if SY-SUBRC <> 0.
    Error handling
      endif.
      concatenate lv_tmp '\' into folder_path.
    But need to know in the lower versions like 3.1h and 4.0,

  • How to get the document path of the pictures uploaded for products?

    Hi Gurus,
    How to get the document path of the pictures uploaded for products uploaded through tcode COMMPR01?
    Many Thanks,
    Neeraj

    client path.
    I need to get the client path in order to download files form server to client.
    Best regards,
    Huy.

  • C Programming: How can we get the filesystem name for a given file-path?

    C Programming: How can we get the filesystem name for a given file-path?
    Say I have a filepath=/mnt1/file1
    Using some OS API like stat, can I get the Filesystem /mnt ?
    Thanks in advance,
    -V

    Enter the command up to the point of entering the file path and add a space, then drag the file into the terminal window. It will fill out the path.
    If you need to go further into the contents of the Application package, you can continue with /Contents...
    Another way is to start typing and then hit Tab to auto-complete. It will stop where it can't determine the next letter.
    So, type /App tab and it will fill in /Applications. Type a / and start with the name of the app, then tab and it should complete. Continue till you have the correct path.
    Spaces will be replaced with \<space>, so, App Store would end up as /Applications/App\ Store.app

  • Firefox will not show links to flv files. I get the error message for each flv file: "File not found. Firefox can't find the file at (path) .flv." Any mov and swf files in this same path will show. I can see the videos in Safari so the paths are correct.

    Firefox will not show links to flv files. I get the error message for each flv file: "File not found. Firefox can't find the file at http:// (path) .flv." Any mov and swf files in this same path will show. I can see the videos in Safari so the paths are correct.

    Is this a webpage that contains a link to a flv file? Please post a link to the page and tell us which link(s) are the problem flv files or else post a link to the .flv file itself.
    Alternately, click on one of the sample FLV File links on this page and tell us exactly what happens:
    http://www.mediacollege.com/adobe/flash/video/tutorial/example-flv.html
    It might also help if you post the exact error message, including the path to the flv file.
    '''Note:'''
    Depending on how you have Firefox set up, clicking on a FLV File link will either save the FLV file to your computer or Firefox may open it automatically in an external application right after downloading (Firefox may ask you first). Firefox itself can't play FLV files so you need a "helper" application (or a plugin for flv files, if ther is one. You can see if Firefox is already set up to download or open FLV files by going to Firefox Preferences and looking in the Applications list. Find the FLV file type in the list and, if the action is "Open with", it should show the application that can play FLV files (e.g., VLC Media Player or Perian). See [[Managing filetypes]] for more information.

  • How do I get iTunes to show the file path for music

    I am trying to get iTunes to show me where songs are located on my computer,  Hoiw do I get this to show up in iTunes?  Thank you

    PTIIIk wrote:
    I am trying to get iTunes to show me where songs are located on my computer,  Hoiw do I get this to show up in iTunes?  Thank you
    Right-click the track in the library, and choose Show in Windows Explorer.
    If you were hoping to get the file path displayed in a column, as is possible in Windows Media Player, note that iTunes does not have that ability.

  • I need to get the current assignee for a given request using SOA's java api

    I'm developing a spring app that interfaces with Oracle SOA suite and executes the actions such as approving requests using the api. I need to get the current assignee for each SOA Task this is dispalyed in the OIM console so it is getting it from somewhere. I tried getApprovers in the ITaskService api but this returns an empty list

    I have checked it once again and there indeed are links for ALUI components for Solaris on SPARC at edelivery.oracle.com. (Officially ALUI supports Solaris on SPARC only)
    If you have looked at Solaris x86, then you must not have found them. Please make sure that you are selecting the righ platform. Also, make sure that you click on the Aqualogic media pack so as to get the lists of the components included in it. (Point to Note: You need to go to the next level)
    For whichever component you are not able to find, try looking for it in the Metalink (My Oracle Support) if you have a support contract.

  • Relative path for servlet property file.

    I have the following java file. When I use the absolute path for the configFile, it works. I would like to know how I could use it as relative path as in installation, the name of the directory could change.
    How do I fix the problem? Thank you.
    ---------------------- LoadProperties.java ----------------
    import java.util.*;
    import java.io.*;
    public class LoadProperties {
    private String driver="";
    private String dbURL="";
    private String login="";
    private String password="";
    static public void main(String[] args) {
    LoadProperties lp = new LoadProperties();
    } // main
    public LoadProperties() {
    //String configFile = "C:/1LMS/web-app/WEB-INF/config/db.properties";
    String configFile = getClass().getResource("config/db.properties").toString(); <--- This line could not find the db.properties file.
    Properties Prop = new Properties();
    try {
    FileInputStream configStream = new FileInputStream(configFile);
    Prop.load(configStream);
    configStream.close();
    } catch(IOException e) {
              System.out.println("Error: Cannot laod configuration file ");
    driver =Prop.getProperty("driver");
         dbURL = Prop.getProperty("dbURL");
         login = Prop.getProperty("login");
    password = Prop.getProperty("password");
    printResult();
    } //Load Property
    private void printResult() {
         System.out.println("Driver = " + driver);
         System.out.println("dbURL = " + dbURL);
         System.out.println("Login = " + login);
    System.out.println("PSWD = " + password);
    } // class

    hi there,
    had the same problem... you need to use following API:
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
    In your case something like that:
    // get the servlet context
    ServletContext context = getServletContext();
    // directory name where the file is located
    String realPath = context.getRealPath("/config");
    // get real path to your file
    String propertyPath = real+"filename.txt";
    hope that helps!!
    minu

Maybe you are looking for

  • Convert binary to text in Forms 6i

    Hello. I used an option called Convert (File/Edministration/Convert) in Forms 4.5 and i could to see the triggers' code in a fmt file; but now with Forms 6i I can't see them any more; somebody knows why? Thanx... Regards Paco

  • Problem with Customer Interaction Module in Web Channel Builder

    Hello Everyone, Facing an issue with Web Channel Builder Customer Interaction Module. In Web channel builder we have done all the required configuration changes, but still we are not able to get the reviews and rating part in the product detail page.

  • TS3276 i turned on my computer today and my mail will not open?

    I have Lions and for some reason when I turned my computer on today my mail will not open? Any suggestions? Evelyn

  • Not opening pdf docs from websites

    We recently installed Adobe Acrobat (full version) 7 onto our computers.  For some reason it will now not open any docs that are pdf's from websites/webpages which has rendered my computer virutally useless as I'm an insurance agent and 90% of what I

  • HT3702 Using a card issued in another country on a different countries AppStore!

    Its been ages since I have been using my Bank of Maldives credit card on a Sri Lanka AppStore (BECAUSE MALDIVES IS NOT AN OPTION) and last week due to no balance iTunes store was not able to debit the amount from my card and now when I deposit the am