Simple question about JAVA path

Hi. I have a simple question , but I spent several hours trying to find an answer.
How do I know the location of the java executable which is used by Concurrent Manager.
I already know that running which java under application user will not give me the correct answer

Maybe you can try like this:
     public String getPath(){
          Class cls=getClass();
          String className=cls.getName();
          String packageName=cls.getPackage().getName();
          System.out.println(className);
          System.out.println(packageName);
          String newClassName=className.replaceAll("\\.", "/");
          String resouceName=newClassName+".class";
          System.out.println(resouceName);
          URL url;
          url=cls.getClassLoader().getResource(resouceName);
          String path="";
          path=url.getFile();
          return path;
     }

Similar Messages

  • Just simple question about java HTTP session mechanism...

    I have one simple question regarding the java HTTP Session Mechanism.
    1) Is there another alternative for the HTTP Session ? If have, what the alternative?
    2) I have been acknowledge that HTTP session is same as cookie system and others say have many different, where is the different..
    thanks

    1) You can always do your own session handling. But why bother when there is one there for you?
    2) The issue with sessions is how to identify the user from the request. Each session gets given a session id. The user has to send that session id with every request they make.
    The standard way is to use a session cookie, which only lasts as long as the browser session. The cookie with the JSESSIONID is sent with every request, thus the server can identify which session a user is in from their cookie.
    Of course you cannot assume that the browser will support cookies, so you need to encode all URLs with the method response.encodeURL(). That method puts the session id into the URL if the browser does not support cookies, or they have them switched off.

  • Simple question about java.rmi.registry.Registry

    Hi,
    where the object java.rmi.registry.Registry takes a URL to rmiregistry when perform bind method.
    thanks.

    Ok, will try to explain.
    I have a server that I register in the RMI registry. Client from a remote machine get the server (as a remote object) and calls his method for the generation of another object on the parameters passed. The server creates this object and tries to register it in the RMI registry, and this raises an exception Registry.Registry.rebind disallowed; origin /11.0.10.31 is non-local host.
    11.0.10.31 is a IP - address of the client

  • Simple Question about java

    Hi all,
    i have one doubt that is
    JLabel lblName = new JLable("String");
    Font f = new Font("Times New Roman", 0, 14);
    lblName.setFont(f);
    I used in one programm and compiled with Java1.1.8
    and run the ptogramm but the font hasn't changed
    If I use java1.2 its Changing So what is the Difference btw
    java1.1.8 and java1.2
    java1.1.8 doesn't support Font???
    please confirm my doubt
    thanks
    byeee

    I think it's the times new roman that's being supported since 1.2.
    Kind regards,
    Levi

  • Three questions about Java and Ftp

    Hello, i've the following questions about Java and Ftp:
    1- .netrc file is in $HOME directory but i can't access to this directory from java code. The following line producesan Exception (directory doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");
    2- .netrc file must have the following permissions: -rw- --- --- but when i create the .netrc file the following permissions are on default: -rw- r-- r--, how can i change this permissions? (In java code, i can't use chmod.....)
    3- Are there any way to pass parameters to a .netrc file? If i get to do this i needn't change the permissions because i can't modify or create/destroy this file.
    Thanks in advanced!!!
    Kike

    1- .netrc file is in $HOME directory but i can't
    access to this directory from java code. The
    following line producesan Exception (directory
    doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");$HOME would have to be replaced by a shell, I don't
    think you can use it as part of a legal path.
    Instead, use System.getProperty("user.home");
    Ok, thanks
    2- .netrc file must have the followingpermissions:
    -rw- --- --- but when i create the .netrc file the
    following permissions are on default: -rw- r--r--,
    how can i change this permissions? (In java code,i
    can't use chmod.....)Yes, you can: Runtime.exec("chmod ...");
    I need to use estrictly the .netrc with -rw- --- --- permissions
    Yes, i can use Runtime.exec ("chmod ..."); but i don't like very much this solution because is a slow solution, am i right?
    3- Are there any way to pass parameters to a.netrc
    file? If i get to do this i needn't change the
    permissions because i can't modify orcreate/destroy
    this file.I don't think so. Why do you need the .netrc file in
    Java at all? Writing a GUI frontend?I want to use automatic ftp in a java program and FTP server, the files and path are not always the same, so i can:
    - modify .netrc (for me is the complex option)
    - destroy and create a new .netrc (is easier but i have permissions problem)
    - use .netrc with parameters but i haven't found any help about it
    Thanks for your prompt reply!!!!
    Kike

  • Simple question about mount and delay script

    Hello, I have a simple question about mounting volumes on start up.
    My computer wakes up auto - and then auto there are serveral applescript tasks (mount and start up programs)
    I use this script (daily) for serveral connections with external volumes I always need the connect to. ( In the script I use this code 3 times for other locations) I do this on start up.
    set Uname to "XXX"
    set Pword to "XXX"
    set someVolume to "afp://XXX.XXX.XXX.XXX/XXX/XXX
    mount volume someVolume as user name Uname with password Pword
    (same code for 2 other locations)
    When i do this on start up sometimes the script says there is no connection possible. I guess it's because on start up the connection isn't there. And 1 minute later when computer is total ready the connection is ok. When I run the script then It works. Just sometimes ( In the morning) 'It' want to connect but the script stops. When i do it manually(I run the script again) it works just fine.
    Is it possible that I need a delay? Can someone explain this?
    How would I make a delay handler for this script? Is that the best solution?
    Thanks in advance. This is something small i'm wondering about.
    Colin

    BTW, If you saved the script as an application +(and not as an application bundle)+ you could drop the script on to *Drop Script Backgrounder* (freeware).
    Then the script would run in the background, so, you wouldn't see it running in the Finder.
    <http://www.macupdate.com/info.php/id/7922/drop-script-backgrounder-x>
    Tom

  • Question about Java's HttpServer: Threading? Backlog?

    Hello,
    I have two questions about Java's HttpServer (com.sun.net.httpserver). From the JavaDoc:
    >
    Management of threads can be done external to this object by providing a Executor object. If none is provided a default implementation is used.
    >
    How can I get information about the default implementation in 1.6.0_13? Do you know the behavior? From my observations, the default implementation uses no Threads, meaning every request is handled in the same Thread, this results in handling the requests to the HttpServer one after another.
    Is this right?
    The second question is about this, also from the JavaDoc:
    >
    When binding to an address and port number, the application can also specify an integer backlog parameter. This represents the maximum number of incoming TCP connections which the system will queue internally. [...]
    >
    When setting the backlog to -1, it uses the systems default backlog. How can I determine the systems default backlog? Can some lines of Java code reveal it (there is no getBeacklog() method)? Or is it up to the Operating System (we use Redhat Linux)?
    Thanks a lot for your help!
    Regards,
    Timo

    How can I determine the systems default backlog?You can't. There is no API for that even at the C level.
    Can some lines of Java code reveal itNo.
    Or is it up to the Operating System (we use Redhat Linux)?Yes. Linux provides a large default. It seems to be at least 50 on most platforms. This is not something you should be worrying about.

  • A simple question about combo box

    Dear All,
    Just got a simple question about combo box: I have one of these selectors with labels based on filtered rows from a table.
    Is it possible to have one more label that would select all options?
    Like:
    Product A
    Product B
    Product C
    All Product
    Many thanks for your help!
    Gilles

    Hi Gilles,
    The purpose of ComboBox itself to select single option out of many.
    For your purpose, you may have to use "List Builder" which can accomodate 1 or more  to select.
    Please revert for more clarification if you need.
    With best wishes
    BaaRaa.

  • A simple question about performance!

    Hi! I have a simple question about performance. Suppouse that you have a servlet or a class with DB access, and you need to use a value several times in that page. What is best, to assign the value from say, a resultset or a request.getParameter() to a variable or to call the resultset or the request every time you need to retrieve that value? Which option uses less memory, which is faster, etc.?
    Hoping the best fou u
    Raul

    If you need more values from a db, the best is to open some connections (connection pool) and use the for accessing the db.
    To get the data only once, open the connection, get the data, store the data whereever you want: variable (class), hidden control (if you want to send from one page to another by request) and close the connection as quicky as possible.
    The advantage of the first method is that the most time consuming activity (connections opening) is done only once.

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • Simple question about flex and AS 3.0

    Hi, this might sound like a simple question so I apologize...
    I have both a copy of flex 2 and 3, and i want to simply code in AS
    3.0 not mxml. I referred to the help of both flex 2 and 3, and all
    i could come up with is "you can add dynamic behavior to your
    documents using actionscript", which means to me, you only write
    your functions in AS and create instances with mxml (...ugh).
    personally, i find mxml to be ugly (mainly because it looks like
    html to me), and i'd rather not use it. coming from programming in
    an IDE in Java, it seems like it would be nicer to have something
    similar, all the while having the power and cool features of flash.
    I'm not fully educated in this matter so i understand that i could
    be totally wrong.
    i mean, if i have to code in mxml, i will. i'm a web
    programmer for a living, and if a more experience programmer said
    something like "if you don't code mxml in flex, you'll never get a
    job coding in flex", i would trust the advice, and learn the ugly
    code. :)
    yes, i do have Flash cs3, it's great but it seems like a pain
    to me the way you organize classes.... i've only seen a few
    tutorials, ones that explain how you cannot simply import a custom
    class, you have tell your movie to link to it, put it in the same
    directory, or manually name the package, it's sort of confusing.
    my main point here is that i'm very eager to start building
    apps in straight AS 3.0 instead of using flash cs3 (for some
    projects), and it would be cool to get some help or be pointed in
    the right direction.
    to simplify:
    can i write AS 3.0 and only as 3.0 in flex 2 or 3? how? can
    you link me to a tutorial? any advise?
    thanks!

    Hey William, thanks for the post. It's a great coincidence
    because I'm reading that book as well. I'm about half way through
    it, and I love it. I installed mxmlc on my linux box and am writing
    pure AS 3 apps. I think that's the way to go, though I know it's
    not for everybody.
    My problem with mxml is that it has a weird syntax for
    function calls, and it's not as 'intuitive' for a person like me,
    who came from C++ and Java programming in the past. I like writing
    programs in the C++ and Java style syntax, and since so many other
    languages use a similar syntax, I don't see any reason to learn the
    nuances of mxml, unless I was getting paid to do it. As far as I
    can tell there is no benefit.
    I hate using Flash to write flash apps as well, I feel like
    they become messy and confusing, especially when trying to write an
    OOP application. I only use it if I want to move an object in a
    very specific way and can't do it with the Tween methods.

  • Question about Java apps structure

    Hello guys,
    I'm a professional C++ programmer and I would like to start learning Java. I'm reading about Java from here and there and would like to ask you about how a java program is structured compared to C++.
    So in C++, I have main.cpp (or any other file name, doesn't matter), which contains a the main() function, and I have .h and .cpp class files that I instantiate (basically) in my main function to get my program to work.
    In Java, I'm confused and can't really find the "general" rule to how stuff are organised. I noticed that every class has a main function (why?), and there's no global scope. And "somehow", file names must exactly be equal to the class names.
    The question is: how are Java files of classes (and other stuff, if available) are arranged to create a program? What's the standard why? And How can I have many classes together in a single main()?
    Thank you for any efforts :-)
    Edited by: 927494 on 13.04.2012 07:02
    Edited by: 927494 on 13.04.2012 09:10

    Thank you guys for the replies. I still have some more doubts :-)
    Do I have to have a file for the implementation and a file for the definitons, like cpp and header files? or just everything inside the class?
    Why does Netbeans fail to compile when I change the class name? what should I change with the class name in general to have it compile correctly? From what I understand till now, the top level class's name (the class with the main() function that's gonna be executed) has to be equal to the file name (and I got that this is the sufficient condition for the app to compile), while the same file can have more classes if I wish. Did I get that right?
    I don't know if I get that right too, we pass only a SINGLE class/file to the compiler, and it automatically resolves ALLLL the included files automatically, unlike C++, where all cpp files have to be passed to the compiler/makefile to create object files, and then the executable is created after linking all those object files with the libraries together. i.e.: Java doesn't really need a makefile because making is really simple with only 1 filename. True?

  • Some questions about Java deployment steps and techniques

    All my java experience is coding and testing in my local machine (where, of course, a jre is available), but ... when I deploy to other people, they may not have a jre or they may have a different version of it than the one needed to run my application. I've read different stuff online including jars and java web start but still I have many questions.
    (1) first one first, Sun contradicts common sense, when it says that i can redistribute my own customized light version of their jre by taking out some files (java.sun.com/j2se/1.5.0/jre/README). there are two ways for me to get a jre: Way one is by downloading one from Sun, the download comes as an *.exe file and I don't see how I can take files out of it, so do you know how?. Way two would be by simply copying the set of files i choose (according to that Readme) from my current jre installation (the one on my \java\jdk\jre directory), does this make sense?, (if you're under windows) doesn't an installed version of a jre need a couple of dlls plus some new registry entries?, this contradicts common sense, if I'm not wrong, that Readme is a nonsense, but since that readme is at each of us jre installation \java\jdk1.x\jre\Readme, it can't be a nonsense, therefore I'm wrong, therefore the answer is either Way 1 or Way 2, HOW? ... or maybe there's a Way 3?
    (2) Say I never read that Readme so I download the jre (as an exe) to bundle it along with my application in a jar ... now I'll give my neighbor either a jar with two exes or two exes jars ... is there a way to make a jar so that two files get executed? ... if the answer is No and I have competition from a second neighbor, then I believe I'm asking my first neighbor to choose my application based on our friendship, that's not reasonable if we are doing business, so Java loses.
    (3) Say that my application is a single executable file like this,
    class X{
    public static void main(String[]$$$){
    System.out.println("Console, where are you?");
    At this point, say that my neighbor accepted the two executables, he executed the jre.exe and has jre6 in his system, now he double clicks on my X.jar ... it's a console application and jar files are not associated with the java.exe launcher since java 5, but with javaw which doesn't open any console ... how do i make it so a console opens and prints "Console, where are you?" ... do I ask my neighbor-customer to add a couple of lines to his path and open his console and (please) enter java -jar jarfile.jar? ... isn't it too much? ... i hope i'm wrong cause this is kind of discouraging
    (4) I've read that by installing a more recent version of a jre on a system that has an older jre (there to help other applications work), I might be causing a problem for the other applications to run ... I guess that's the reason why that Readme kind of encourage to redistribute a "private" version of a jre (one that doesn't come with a java.exe launcher ... any feedback on this?
    (5) I'm reading a lot of hype about Java Web Start ... it looks better than the traditional jar/jre deployment ... but setting up a MIME type to *.jnlp, it doesn't come with some free hosting I've checked ... somebody can recommend a free hosting service that allows to set a *.jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... and, anyhow, how you people compare it with the paradigm of the single executable file?.
    Thanks. Your feedback is highly appreciated.

    jorgelbanda wrote:
    ..(5) I'm reading a lot of hype about Java Web Start ... It's gratifying to think that someone who wants to deploy apps., has the common sense to search first! You would not guess how I often I hear "I wanna' make an EXE" shortly followed by "What's webstart?".
    ...it looks better than the traditional jar/jre deployment ... but setting up a MIME type to .jnlp, it doesn't come with some free hosting I've checked ... OK. You cannot define new mime types, but perhaps the site already has it defined. An easy way to check is to upload 'any old file' that ends in .jnlp and use the [mime type checker|http://pscode.org/mime/] to see what content type it is served as.
    ..somebody can recommend a free hosting service that allows to set a .jnlp MIME? (I'll appreciate a suggestion here, cause I would like to test Web Start)... I'm pretty sure the Google based sites offer it.
    Note that I edited the asterisks out of your post, to avoid the forum software parsing half the reply as bold.

  • Question about Java Errors

    I have some questions about some java errors
    1. what kind of errors are contained in Error class?
    2.does this class contain only runtime errors?
    3. if the question number 2 is positive, what about InstantiationError which is a compile error and is a subclass of Error.
    4.When our program is out of memory, which processes are done for an error to be produced. is the error actually from OS or VM?

    I have some questions about some java errors
    1. what kind of errors are contained in Error class?An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.
    2.does this class contain only runtime errors?No
    3. if the question number 2 is positive, what about
    InstantiationError which is a compile error and is a
    subclass of Error.
    4.When our program is out of memory, which processes
    are done for an error to be produced. is the error
    actually from OS or VM?Various - both, depending on where the error occurred.

  • Question about java-based server app frameworks

    Hello, I am working on a Java applet application and would like to choose a Java-based scalable server framework to use within my applcation. I have found a few like xsocket or QuickServer and have a question about other. And, also, which is the one You may advise? Yours sincerely, Slawek

    For online gaming server. I first heard of xsocket and started using this, but have the problem with NAT. I now know that I need to initiate connections from client behind NAT (server has a public IP) and send messages from server to client within the same connection. I am doing this the following way (as shown in examples- below), but it appears that server receives messages, but client doesnt. I dont listen on any ports in client application and just need to take advantage of the connection initiated (information go from client to server properly).
    Server-
    try{ nbc = pool.getNonBlockingConnection(inetAddress, 8090);
    try{ nbc.write("|01|______|02|______|03|______|04|______|05|______|06|______|07|______|08|______|09|______|10|______"); }catch(Exception ee){}
    }catch(java.io.IOException f){}
    Client-
    public boolean onData(INonBlockingConnection nbc) throws IOException,ClosedChannelException,BufferUnderflowException,MaxReadSizeExceededException{
    String x = nbc.readStringByLength(100);
    System.out.println("S >> C = "+x);

Maybe you are looking for

  • Help about Solution Manager Maintanence Optimizer

    Hi All,     I have a small confusion how to follow the configuration of Maintenance Optimizer in Solution manager. Yesterday i installed the solution manager and assigned the ECC server to that solution manager using SMSY transaction. Now i have to c

  • Not found sdoapi java classes

    I just reinstalled Oracle9i with patch, because I wasn't able to create spatial index (that's the short explanation for reinstalling oracle). ERROR: Critical Java class not found: oracle.sdoapi.util.SDODimElement ERROR: Critical Java class not found:

  • Pen lines in Photoshop CS4

    I want to tidy-up a scanned diagram saved as a TIFF. The diagram consists of many (almost) vertical and horizontal lines which I want to straighten and color. The Pen Tool seems ideal for this, as you can constrain it to 45 degree steps. I have never

  • How to download ncis episode from itunes

    trying to download episode 21 of ncis season 3 and having a hard time. There is no download icon.

  • RV042 - PAT not working

    Hi, I have to access different machines behind the RV042 on the ports 80 or 443. Each machine can be reach localy on the private IP address. So if i read it right I have to configure the UPnP feature to do the translation but it does not work: HostA