How 'java' handles classname passed to it

Hi,
After compiling the .java file, the .class is passed to 'java'
and that runs the program.
Does the 'java' work this way: when we give "java classname", 'java'
strictly would search for classname.class and proceeds thereafter,
The reason i got this doubt is when i gave a command "java
classname.class" an error was raised pointing no class definition.
Thanks for your time.
Kris.

When the java virtual machine looks for a class it uses a ClassLoader. What the default classloader does is:
1) Converts any dots in the "fully qualified name" to the appropriate path separater / or \ depending on the operating system.
2) If it's an inner class, the inner class name is separated from the outer class by a $
4) adds .class to the end
5) Walks along the CLASSPATH. For every directory on the CLASSPATH it adds the string processed above and looks for a file. For every .jar file it tries to find the entry of the same string.
Note "." in a classname is used to separated package name from class, as in java.util.Map, for example. "classname.class" would look for a class called "class" in a package called "classname".
You can't compile a class called "class", by the way, because it's a reserved word.

Similar Messages

  • Confused about CLASSPATH and how java handles import statements...

    Hello,
    I must admit I don't get it. I read the articles about setting CLASSPATH etc. but I still wonder:
    If you use an import statement, what does the compiler do? I.e. where does it look for the specified classes? I find it confusing because I see in different locations different .jar files:
    C:\jdk1.3.1_03\lib\dt.jar
    C:\jdk1.3.1_03\lib\htmlconvertor.jar
    C:\jdk1.3.1_03\lib\tools.jar
    and also
    C:\jdk1.3.1_03\jre\lib\i18n.jar
    C:\jdk1.3.1_03\jre\lib\rt.jar
    C:\jdk1.3.1_03\jre\lib\jaws.jar
    C:\jdk1.3.1_03\jre\lib\sunrassign.jar
    Can someone explain me what the purpose is of these files?
    And why do I have the same contents in
    C:\Program Files\JavaSoft\JRE\1.3.1_03\lib
    and in
    C:\jdk1.3.1_03\jre\lib
    Why is that?
    Thanks for answering my questions!
    -mike

    Thanx for the answers, but I still wonder, everyone
    here says I need to set the classpath, but I don't.Probably because your classes are already in the class path. The compiler/jvm also look for classes by themselves not just in jar files, when just a directory is supplied in the class path. And a period (".") is a valid directory.
    Programs importing different classes compile with no
    problem. So what's up with that?
    Presumably you are referring to your own code - because they are in the class path.
    Second, I still don't understand why the runtime needs
    the .jar files. The runtime uses classes, like String, that have to come from somewhere.
    This would also mean that end-users
    need to set the classpath to the .jar files in their
    JRE directory to be able to run programs that import
    classes from these .jars. But this is not true, right?No it is true. The end-users will have to set the class path. There are variations on this which make it seem like no class path is set. For instance applets in a browser are java but the end-user does not need to set a class path. That is because the browser knows how to download classes/jars and how to set it up so it uses them. (Actually it uses a class loader, but that is probably more information that you need.)
    Because if I make some nice classes myself and import
    them, how can I expect my end-user to install these
    classes and make a classpath for them?That would be between you and you end-user.
    First installation is not part of java. For installation you will have to find something outside of java to accomplish the goal.
    Additionally how the class path gets set is OS specific. Java does not deal with that. You will also have to find some way to deal with this (most likely part of the installation.)
    There are also variations on this. For example the browser example I gave above. Or using the ext directory. Or creating an executable jar. Or simply setting the class path.
    In my understanding it should only be needed in the JDK, not
    in the JRE. True or am I mistaken?Mistaken. The class path is needed in the JRE as well. You will need to set it.

  • How java handles package/class names

    I am developing a strategy for internationalizing our company's middle-ware product. While I have no problem with the GUI's, exceptions, log files etc, I have no concept of how things like classpaths and packages can be specified in an asian language.
    For instance, if I have configuration information of com.abccompany.mypackage.MyClass, what will this look like to the asian user? Will they be able to change it to perhaps com.abccompany.mypackage.MyClass2 by entering localized data in Chinese or Arabic? I don't understand how this part works. On the command-line, will they type English script names? Do they run commands like so: java -cp com.abc.pkg1.jarfile.jar MyClass? Will my english filenames, packages, etc be represented in asian characters?
    We have a lot of configuration information that specify java classes as String data. I am concerned about the ability to modify this data and have it work correctly in languages that do not use the ascii character set. Is this something I need to be worried about?
    I appreciate any input. Thanks in advance.

    You do not need to warry about configuration information of com.abccompany.mypackage.MyClass
    and command-line no matter what languages used in Asia. Asian users also type in English script names or java -cp com.abc.pkg1.jarfile.jar MyClass as you do so. The only thing you need to note is
    that any text strings or messages which you want to show on any panel/dialog/window/frame and so on should be store in a resource file for internationalizing.

  • How to Handle excise pass-on in SAP-B1 for Trading companies?

    Hiii Experts,
                         Currently, we have new project and our client is trading company. As a trading company, there is not any credit of excise will be taken. just pass-on of excise duty is done from vendor to customer as it is.
                         As per my knowledge, there is not any provision available in SAP-B1 to track the details of  excise pass-on. is there any way is available to handle this excise scenario's for trading clients??
                           Please, help me, it is very important to us.
    Regards
    Rahul Singh

    Hi Rahul,
    Yes this can be customized in SBO with or without add-on.
    First step would be understand the complete business process of  the customer and then map in SBO accordingly.
    You would have to create many udf's at row level to capture the details at the time of purchase and you can use the same references at the time of sale of the item.
    As I have mentioned before, it may take extensive customization, so you can decide whether you woudl like to create an add-on for it or woudl you like to handle this through SP, fms etc.
    Thanks,
    Joseph

  • How Java handle duplicated class?

    I am trying to send out email using SUN JavaMail. However, an old version of JavaMail was shipped with Oracle AppServer 10 R2. If I package the new JavaMail into the WAR file, the old JavaMail is still functional, and cause problem to my program. Is there a way to tell the AppServer to use the JavaMail in my WAR file instead of the old one shipped with the server?
    Thanks very much!
    Edited by: huaichen on Nov 6, 2008 2:02 PM

    Hi,
    does this help you? It's from an older vesion but might wor kin your case.
    How do I setup OC4J to load local classes packaged in my Web Application overriding System classes or classes in the higher level?
    OC4J 9.0.3 has a configurable option to load local classes first, overriding classes at a higher level. You have to include the following to directive in the orion-web.xml for your web module to ask OC4J to load local classes:
    <web-app-class-loader search-local-classes-first="true" />Timo

  • How do Streams work?  I mean specifically, how Java handles it

    I mean this...this is my code
    class Wilson implements ConstantsBase
         public static void main(String[] args) throws IOException
              Maze mazeArray = new Maze();
              int count = 0;
              int character = System.in.read();
              while (character != -1)
                   System.err.println(count++);
                   System.out.print((char)character);
                   character = System.in.read();
              mazeArray.printMaze();
    I run java Grid.Wilson and then the prompt comes up and I type
    "test"
    the output is
    test
    0
    t1
    e2
    s3
    t4
    5
    so I am just wondering, does it work like this:
    streams comes in chunks, everytime you hit enter, a stream is released. So that is why even though my code looks like it should be outputting one letter at a time, each time I type, it actually won't get a stream until I hit enter, then it gets this stream and goes through the loop. But it is still weird in my head, I wish I had a trace option on this IDE

    A stream is just a sequence of bytes in the case of 'in.read(char)': - I believe I read somewhere that a java char is two bytes, then there may be an additional identifier so the output/ program knows what it is - int, char, or string etc. In the case of your output i would 'guess' its a little chunk of bytes then another.

  • How Java handle event??

    for example,An application want to receive the event of KeyBoard,The event Should be received by OS ,I think.and Then??OS Should send the event to Where ?? Who would receive the event??Wher does Application receive the event ??

    He, I now I remind : Look at the end of
    http://forum.java.sun.com/thread.jsp?forum=57&thread=293208
    But note that there is no unique response to your question: It's hihgly dependant of your JVM and of your OS.

  • How to handle comma separated values in OLE DB Source query for a parameter variable from XML file in SSIS

    Hi,
    I am using OLE DB Source to fetch the records with Data Access Mode as SQL COMMAND which is using the below query with a parameter,
    SELECT CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation, EMP.HireDate, EMP.BirthDate,CON.EmailAddress, CON.Phone
    from HumanResources.Employee EMP INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in (?) 
    In this query for the parameter I am passing the value from a variable and which is configured (XML Configuration). While passing value
    Buyer it works correctly. But while passing values Accountant,Buyer
    it is not working as expected.
    How to handle while passing such multiple values Or is it possible to pass such values or not in SSIS 2012 ?
    Kindly help me to find a solution.
    NOTE: I placed the whole query in a variable as a expression as below it is working fine.
    "select CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation,EMP.HireDate,EMP.BirthDate,CON.EmailAddress,CON.Phone from HumanResources.Employee EMP
    INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in ('" + REPLACE(@[User::temp],",","','")  +"')"
    Any other solution is there ? without placing the query in a variable. May be a variable can have some limitations for no. of characters stored not sure just a thought.
    Sridhar

    Putting the whole thing into a variable is certainly a valid solution.  The other involves putting the comma delimited list into a table valued variable.
    http://gallery.technet.microsoft.com/scriptcenter/T-SQL-Script-to-Split-a-308206f3
    For an odd ball approach: 
    http://www.sqlmovers.com/shredding_multiline_column_using_xml/ .
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How to handle the date attribute,passing parameter from one page to another

    hi Friends,
    i want to pass data attribute from one page to another page-
    i am passing like below ,in jdev log window i am getting below error.
    String StatusUpdateDate = row.getAttribute("StatusUpdateDate");
    params.put("StatusUpdateDate",StatusUpdateDate)
    Error(121,50): incompatible types; found: java.lang.Object, required: java.lang.String
    Suppose i am passing like below , while moving one page to another i am getting below error in application
    String StatusUpdateDate = row.getAttribute("StatusUpdateDate").toString()
    Status Update Date - JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value:26-MAR-2009
    please can any suggest me how to handle this error.
    Thanks and Regards,
    vamshi

    Hi Pratap, Thanks for your help
    it was my mistake that previously property it was varchar2, now i have changed as you suggested every thing. still i am getting error. this is my code-
    AM CODE-
    public void xxselection(String Name, String Email,String Product,String Region, DATE StatusUpdateDate)
    DetailVOImpl vo1=getDetailVO1();
    vo1.initQuery2(Name);
    Row detailRow = vo1.createRow();
    detailRow.setAttribute("Name", Name);
    detailRow.setAttribute("Email", Email);
    detailRow.setAttribute("Product", Product);
    detailRow.setAttribute("Region", Region);
    detailRow.setAttribute("StatusUpdateDate", StatusUpdateDate);
    vo1.last();
    vo1.next();
    vo1.insertRow(detailRow);
    detailRow.setNewRowState(Row.STATUS_INITIALIZED);
    Controller- Process Form Request- Source page
    if (pageContext.getParameter("Detail")!= null)
    String Name=row.getAttribute("Name").toString();
    String Email=row.getAttribute("Email").toString();
    String Product=row.getAttribute("Product").toString();
    String Region=row.getAttribute("Region").toString();
    DATE StatusUpdateDate =(DATE)row.getAttribute("StatusUpdateDate");
    HashMap params =new HashMap();
    params.put(" Name", Name);
    params.put("Email",Email);
    params.put("Product",Product);
    params.put("Region",Region);
    pageContext.putTransactionTransientValue("StatusUpdateDate",StatusUpdateDate); //As you suggested
    pageContext.forwardImmediately("OA.jsp?page=/xxm/oracle/apps/pos/stg/webui/DetailStagePG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    params,
    true, // retain AM
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    another page Controller-Process request-Destination page-
    String Name = pageContext.getParameter("Name");
    String Email = pageContext.getParameter(" Email");
    String Product = pageContext.getParameter("Product");
    String Region = pageContext.getParameter("Region");
    DATE StatusUpdateDate=(DATE)pageContext.getTransactionTransientValue("StatusUpdateDate");
    Timestamp tstmpStatusDate=StatusUpdateDate.timestampValue();
    System.out.println("tstmpStatusDate"+tstmpStatusDate);
    Serializable[] parameters1 = {Name,Email,Product,Region,tstmpStatusDate};
    am.invokeMethod("xxselection", parameters1);
    Error - getting at while running the application page to page
    No method with signature - No method with signature - xxselection(class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String, class java.lang.String)
    every thing is getting passed except DATE Attribute, please check the code and update me
    Thanks in Advace-
    vamshi

  • How to handle the java.policy file ?

    Can somebody tell me how to handle the java.policy file?
    I always get java.net.SocketExceptions and java.security.AccessControlExceptions while connecting to an appserver from an applet.
    What do I have to write in the java.policy file, where do I have to place it and do I have to call it in some way form my applet?
    Thanks in advance.
    don call

    The java.policy file goes in your jre installation directory in .../jre/lib/security (there should be one there already).
    I used it to allow otherwise restricted permissions for an applet using javax.comm. Add something like the following to the file:
    grant codeBase "URL:http://yourDomainName/rootDirectoryOfYourApp/*" {
         permission java.security.AllPermission;
    This will give the applet downloaded from your site all permissions. You might want to give only certain permissions, I don't know.
    Teri

  • How to handle Java popup in oracle forms application through Open Script?

    I want to record and test oracle form application but it popup java dialogue box and Open Script can't handle java object.
    So how to handle the Java popups in forms application?

    Hi, Have you been able to resolve this?

  • How does Java handle / recognizes fonts

    Hello
    can you help me with information regarding how java handels fonts? Especially how the fonts "Dialog" or "Monospace" come into life as i have no such font installed on my system.
    Thanks
    Matt

    Hello
    But there must be more behind it because we wrote a program to test if a font is compatible to the chinese GB18030 standard. This Font tests if a font can display some characters such as &#3858; (\u0F12 TIBETAN MARK RGYA GRAM SHAD). Dialog, Monospace, SansSerif, Serif and DialogInput can all display it. But my system font is set to Thoma, which cannot do it.
    So, what is the mechanism behind the creation of these fonts? Thats what i would like to know :)
    Thanks in advance
    Matthias

  • How to handle special characters in NWDI

    Dear All
    I am trying to update the Description from JSP form. Through JCO we are calling the RFC of ABAP. We are passing these description from Java to RFC of ABAP and this RFC update the text in Database.
    We have noticed that if there is some special character in description like as : š or ž, complete description is not getting updated in to the SAP database.
    Can anyone help me how to handle these special characters in Java. There may be N number of special characters. We want to generalize it. We want to replace these characters by s and z respectively.
    For example : We want to update this description.
    APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 riješen je cleaning procedurom, te je i kroz CSR odgovoreno da trap korekcija N01TCADG-0052 u bloku UPDC više nije potrebna, te se može izbaciti (AP143).
    Uspješno su završene HR17/CN-A3 FOA-e na tranzitnom nivou, te slijedi roll-out u dva termina 12/13.04 i 19/20.04. ETK je na sastanku isporu&#269;io SW, te ALEX i mini PLEX za sve objekte.
    AP147. Poslati finalnu dokumentaciju za uvo&#273;enje paketa (implementacijsku instrukciju i sve popratne datoteke).
    WHile updated text is as follows :
    APPLERR H'4301 H'FA03 H'254C na Zagreb TC4 rije
    N01TCADG-0052 u bloku UPDC vi
    Uspje
    sastanku isporu
    AP147. Poslati finalnu dokumentaciju za uvo
    Regards
    Bhavishya

    Hi Bhavishya,
    Apparently your SAP database isn't configured to support Unicode. That would be the first solution to your problem, but I can imagine it's a bit drastic to convert your DB.
    A second solution would be to encode the input description to ASCII before storing it in the database. When reading from the database, decode again to Unicode. This way, no information is lost. A suitable encoding would be Base64. e.g.
    String description = "šunday žebra";
    String descriptionBase64 = new sun.misc.BASE64Encoder().encode(
      description.getBytes("UTF-8")); // ""
    // store descriptionBase64 in the DB
    // later, when reading descriptionBase64 from the DB
    String description2 = new String(
      new sun.misc.BASE64Decoder().decodeBuffer(descriptionBase64), "UTF-8");
    Instead of using Sun's implementation, a better alternative is to use the open source implementation
    org.apache.commons.codec.binary.Base64 from Commons Codec . 
    The 3rd approach is indeed to normalize the description by replacing all special characters with their ASCII equivalent. A rather easy solution is as follows:
    String description = "šunday žebra";
    String descriptionNormalized = sun.text.Normalizer.normalize(
      description, sun.text.Normalizer.DECOMP, 0).replaceAll(
      "[^p{ASCII}]", "");
    sun.text.Normalizer decomposes the string, e.g. "éàî" becomes "e´a`i^", after which non-ASCII characters are being removed using a regular expression.Again, note that it's usually a bad idea to use sun.* packages, see note about sun.* packages. The above code only works with J2SE 1.4 and J2SE 5.0, but it breaks in J2SE 6.0 (where
    java.text.Normalizer became part of the public API ;-). A good open source implementation can be found here: ICU4J (com.ibm.icu.text.Normalizer). 
    Kind regards,
    /Sigiswald

  • How to handle HTTP-POST encrypted data for ECC Using proxy or RFC

    I have a scenario HTTP-POST ->PI->ECC.sender is HTTP Post  send encrypted data i need to handle the data and stored in to SAP ECC  with out decrypt using PI .what should i take for receiver  can i use inbound proxy or RFC  and how can handle the encrypted data  for decrypt.
    Regards
    Ravi

    1. my sender is HTTP POST . what should i configure in sender communication channel in SAP PI .like SOAP or HTTP .What are the parameters i need to pass .
    >>>
    If you are on PI 7.3 and above, configure the HTTP AAE adapter - Configuring the Java HTTP Adapter on the Sender Channel - Advanced Adapter Engine - SAP Library
    2.while using inbound proxy for encrypted data  i need  store the data in to table , the same proxy can i call  another outbound  service for decrypt  same data.
    >>>>
    Yes you can always a proxy within a proxy.

  • How to handle CLOB

    Hello,
    In my java programme I am picking a huge data from a file and passing it to a oracle stored procedure.
    In my oracle stored procedure I pick data line by line and process and to identify a new line I use CHR(10).
    The problem is, the file containing the data has data in lines but when the data is read and sent over to oracle called procedure the new line is missing and the complete data is found in one line which is very huge. Hence the processing of data fails.
    In Java programme, How should I read the data from the file so that the new line or line terminator remains as it is. Or the data is read exactly as it is in the file.
    Also, the Oracle stored procedure argument is of CLOB type. How to handle CLOB in JAVA, that is, pass more than 32767 chars.
    Thanks & Regards,
    Sanju.

    Your problem is that createClob() isn't implemented until JDBC 4 (which I think will come with mustang). The usual way people deal with new Clob records on Oracle is to create the record, initially, with an empty Clob, read the record back and use getClob to get the Clob, then write to that and update the record. (Pretty aweful)
    A technique I've found works on Postgressql blobs and which is probably worth a try is to write your own, minimal implentation of Clob. All it needs to handle are the length() and getCharacterStream methods (all others throw UnsupportedOperationException or similar. Try feeding one of those through a setClob(). Might work, might not.
    With any luck JDBC will read your stream into the LOB as part of the setClob() action.

Maybe you are looking for

  • Home Server Set Up - DNS, DHCP etc

    Hi I'm looking to set up a Mountain Lion Server at home.  I have a Lion Server but I think I will wipe it and start again, mainly because I didn't use a particularly good name to begin with. I've read the We Got Served Mountain Lion Server book, Moun

  • Crystal Report 9 connectivity with WebLogic 10.3.5

    Hello, Is the Crystal Report 9 certified with WebLogic 10.x? Currently WebLogic 8.x is in use. Trying to upgrade the WebLogic. Thanks

  • Screen flickering/blinking Xperia Z1

    Sometimes my display flickers for a few seconds, doesnt mater where I am on screen, I noticed it mainly in call logs/calling, chrome, home screen and messages. It's nothing major and it's kinda weird flicker, like anti aliasing lines or something lik

  • Extracting files from a PP to create an iMovie

    I have a DVD from my family (nothing copyrighted) that is basically a PowerPoint file with a bunch of different photos set to music. I want to see how I can (if I can) extract those photos so that I can create an iMovie with them, as the PowerPoint c

  • Change the iTunes store an app is associated with

    I have two active iTunes store accounts in two countries because I have homes in both locations (U.S. and another country). These two accounts allow me to download content that is available only in one of those countries to my one iPhone. I know how