Classes & classes

Hey!
I'm an absolute beginner at java and I've encountered my first problem. I've made a class with a couple of methods. My learning book told me to make a testclass, to test the methods of the class i've made earlier. So i've made the test class, but for some reason I get a error when running the test class. No such method. But the classes are located in the same director!
please help
regards

Without your code it's hard to tell - no such method could mean you have your method signature wrong or you didn't get your main method coded correctly or possibly something else - post the test class, and (if it's not too large) the class your testing and the command you used to run your test class. Please place [code][/code] tags around your code.
Good Luck
Lee

Similar Messages

  • Error in using Class class

    This is probably to do with my enviroment having a problem but when I try to compilee ShowMethods.java from Chapter 10 of thinking in Jave (code below after error messages) I get the following error:-
    ShowMethods.java:23: cannot access Class
    bad class file: .\Class.java
    file does not contain class Class
    Please remove or make sure it appears in the correct subdirectory of the classpa
    th.
          Class c = Class.forName(args[0]);
          ^
    1 errorAny ideas?
    Ben
    //: c10:ShowMethods.java
    // Using reflection to show all the methods of a class,
    // even if the methods are defined in the base class.
    // {Args: ShowMethods}
    import java.lang.reflect.*;
    import java.util.regex.*;
    public class ShowMethods {
      private static final String usage =
        "usage: \n" +
        "ShowMethods qualified.class.name\n" +
        "To show all methods in class or: \n" +
        "ShowMethods qualified.class.name word\n" +
        "To search for methods involving 'word'";
      private static Pattern p = Pattern.compile("\\w+\\.");
      public static void main(String[] args) {
        if(args.length < 1) {
          System.out.println(usage);
          System.exit(0);
        int lines = 0;
        try {
          Class c = Class.forName(args[0]);
          Method[] m = c.getMethods();
          Constructor[] ctor = c.getConstructors();
          if(args.length == 1) {
            for(int i = 0; i < m.length; i++)
              System.out.println(
                p.matcher(m.toString()).replaceAll(""));
    for(int i = 0; i < ctor.length; i++)
    System.out.println(
    p.matcher(ctor[i].toString()).replaceAll(""));
    lines = m.length + ctor.length;
    } else {
    for(int i = 0; i < m.length; i++)
    if(m[i].toString().indexOf(args[1]) != -1) {
    System.out.println(
    p.matcher(m[i].toString()).replaceAll(""));
    lines++;
    for(int i = 0; i < ctor.length; i++)
    if(ctor[i].toString().indexOf(args[1]) != -1) {
    System.out.println(p.matcher(
    ctor[i].toString()).replaceAll(""));
    lines++;
    } catch(ClassNotFoundException e) {
    System.out.println("No such class: " + e);
    } ///:~

    This is probably to do with my enviroment having a
    problem but when I try to compilee ShowMethods.java
    from Chapter 10 of thinking in Jave (code below after
    error messages) I get the following error:-==SNIP==
    This is during compile time, correct?
    It sounds like you might have a CLASSPATH error... (a search of the Forums should indicate at least 120000 potential posts involving this issue, since last tuesday ;-))
    It does seem strange--that is the code actually posted from the file "ShowMethods.java" that you have keyed into a notepad editor of some sort?
    What command are you using to compile?

  • What is the use of class Class

    What is the use of class Class?

    Sample use: if you are specifying the name of a class in a config file, you can use Class method newInstance to instantiate it.:
    String classname = ...
    Runnable r = (Runnable) Class.forName(classname).newInstance();
    r.run();

  • Exception in Class class native method

    Hi Guys,
    I am getting an Exception in the Class class native method getMethod0. The Exception is java.lang.NoSuchMethodException. Can some put light on this, as to why is this coming???
    Here's the starckTrace........
    java.lang.NoSuchMethodException
         at java.lang.Class.getMethod0(Native Method)
         at java.lang.Class.getMethod(Class.java:888)
         at com.gepower.gees.vc.utility.VCComparator.compare(VCComparator.java:67)
         at java.util.Arrays.mergeSort(Arrays.java:1181)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.sort(Arrays.java:1128)
         at java.util.Collections.sort(Collections.java:121)
    Thanx,
    Chandan.

    Class.getMethod() throws that exception if the method that is being searched for does not exist.
    And VCComparator.compare() used Class.getMethod().
    So something is wrong in VCComparator.compare().

  • Error in classification (class CLASS-PLANT class type 032)

    Dear,
    I am testing Release procedure in Quality client.....There my colleague  have created one class in quality manually name as CLASS-PLANT  , but when i am clicking in  release strategy "Classification" button ..i am getting this error "Error in classification (class CLASS-PLANT class type 032)
    Message no. ME179
    Procedure
    Please check the specified class or class type in Customizing for the release procedure."
    i have created class CLASS-PLANT class type 032..
    what can be the problem?
    Utsav

    Hi
    Check the following threads it may help you
    Re: error in release config
    PR Release : Error in Classification
    Classification error
    Thanks/Karthik

  • QM Tables for CLASS(Class Number), KLART(Class Type) and MATNR(Material)

    Hi All,
    is there any table which are having the fields : CLASS(Class Number), KLART(Class Type) and MATNR(Material) in QM.
    the above three fields should be in single fields.
    thanks,

    Hi Gupta,
    Go through the AUSP table: Characterstic Values,
                             IFLOT table : Functional location.
    and
                             KSSKAUSP view for required fields.
    by
    Prasad gvk.

  • How to  find a KMAT material, for a given class (class type:300)

    I know the class (class type:300), but I would like to know for which KMAT material is this class is being used. Is there a transaction or table for which I can find

    Hi
    Try the tables KSSK,KLAH. Pass the class value as 300 you wil get all the materials which are assigned to class type 300. you can pass the material to MARA to and filter with material type KMAT.
    Regards
    S.Senthil

  • Load: class .class not found.

    Load: class .class not found.
    java.lang.ClassNotFoundException: .class
    blah
    blah
    blah
    basically just stating where the class is expose to be.
    This is an applet that i try to run its be made on another computer and compiles fine on the other one. I reinstalled my desktop and i downloaded the jdk se 6 release 6 and i use textpad to wright and compile. My problem comes after i compile the first time i try to run the applet i get a ClassNotFoundException but then the second time it works. It is not the biggest problem in the world just a little annoying and something that i would like to fix if i can. Thanks for the help.

    yeah its kinda strange it happens for me every time consistently when a new class file is created with a compile the first time an applet is run it will give then class .class exception that i cant find information on. If there is no class in the folder such as i delete it and then run the applet the class "name".class a cures witch i see a few times on the internet but the first run failing is strange everything is in the right place and the class is in the right folder just the first time it is accessed it will fail but every time after it will work until a new compile and a new class is created
    does anyone else get this maybe i can figure out if its my jdk or my OS or the raid drives messing up or something i cant think of.
    i'm using the 6se update 6 maybe i should try beta release 10 i'm also using the 1.5 3d but i have not worked the bugs out of 3d yet. all on windows xp 32bit i was having to problem with 64 bit also but that os crashed and i haven't gotten to reinstall it. the class file is located in a single drive raid i mean the drive is considered raid but it has no link to the other drives. Drivers i believe to be up to date not more then a couple weeks old if they are.
    I removed and reinstalled the jdk but same problem any information is appreciated. thanks.

  • Classes/class types and characteristics

    Hi!
    In transaction CL03, tab "Char.", you get an <b>overview of the characteristics of the class</b>. Is there a <b>database table</b> from which I can check out these links (between class/class type and the characteristics of this class)?
    Thank you for all your help
    - Mari Virik

    DATA : LT_CHARACTERISTICS TYPE BAPI1003_CHARACT_R OCCURS 0.
    CALL FUNCTION 'BAPI_CLASS_GETDETAIL'
      EXPORTING
        classtype                  = '017'  "TDWA-KLASSENART
        classnum                   = 'ZCLASS_NAME'  "TDWA-KLASSE
      LANGUISO                   =
      LANGUINT                   = SY-LANGU
      KEYDATE                    = SY-DATUM
    IMPORTING
      CLASSBASICDATA             =
      CLASSDOCUMENT              =
      CLASSADDITIONAL            =
      CLASSSTANDARD              =
      RETURN                     =
    TABLES
      CLASSDESCRIPTIONS          =
      CLASSLONGTEXTS             =
       CLASSCHARACTERISTICS       = LT_CHARACTERISTICS
      CLASSCHARVALUES            =
    You will have list of characteristics in lt_characteristics.
    Pass internal table lt_charvalues of type BAPI1003_CHAR_VAL_R to CLASSCHARVALUES, if you need characteristic values as well.

  • What means the " E " in class Vector and " T " in class Class?

    Hi world!
    I was searching in the java docs and in the source code of Java and found a syntaxis that I don't know what mean. This:
    public class Vector<E>
        extends AbstractList<E>
        implements List<E>, ...and this:
    public Vector(Collection<? extends E> c)this too:
    public final
        class Class<T> impleme...and that:
      public static Class<?> forName(String className) well you get the idea. If someone could give me where can I find information about the using of this.
    Tanks

    See the generics tutorial:
    http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

  • Error "You may only define methods within "CLASS class IMPLEMENTATION"

    We have code in LMIGOSMC so that the vendor batch number appears in the MIGO transaction for certain movement types.  We have created another, custom movement type in which this functionality should be available so I need to add it to LMIGOSMC.  When I go in and try to make the modification I am getting the following error:
    "You may only define methods within "CLASS class IMPLEMENTATION ...ENDCLASS".
    What am I doing wrong?

    Hi,
    You are not doing anything wrong with regard to the syntax error you are getting.  During the syntax check of include program LMIGOSMC, the system is not aware of the CLASS... ENDCLASS statements within the program LMIGOSM4.  Try the syntax check at the LMIGOSM4 program level (or even better, at the SAPLMIGO level) and you will see that the error is not given.
    Regards,
    Jamie

  • Java .class files - Moving the Main Class .class file to a new location

    Novice question....so much so that I hope it's even coherent...
    In a Java program which references many associated .class files (e.g. bicycleMain.class, bicycleSub1.class, bicycleSub2.class, etc....), do the associated .class files always have to be located in the same directory as the Main .class file?
    What I'm getting at is - If I've developed an application consisting of several .class files on my own Windows PC and I want to put the compiled application out on our Windows File Server so that anyone can execute my application, how would I go about doing this?
    Say I put the compiled .class files in H:\PROJECTS\JAVA\COMPILED\, will other people be able to execute the application from their PCs by simply issuing the command line:
    'java h:\projects\java\compiled\bicycleMain'
    Any insights would be very helpful in getting me oriented. Thanks in advance.

    Interesting...so are you saying the command line might look something like this:
    java -classpath h:\projects\java\compiled bicycleMain
    And if I want other people to be able to execute the application without specifying the -classpath option then they would need to manually update the ClassPath environment variable on their individual PCs first?

  • Can applet load own security class, class loader

    i tried this own security class extends SecurityManager class but exception thrown as applet cannot initate new security manager class.
    i have done throw policy file entry to allow applet to write file in client machine.
    i feel this extra burden novice user...
    what is alternative way....
    plz..

    An applet should never be allowed to install its own security manager. That is why it is burdensome.

  • Class class

    I have a question about the Class's forName method. How do you make it so that it searches the current directory, if the parameter entered is not one of the java libraries?
    i.e. Class c = Class.forname("Circle");
    Circle is the class I made. It is in the same directory as the class that I am making using the forname method and the exception I get is a ClassNotFoundException.
    Thanks, Hector

    Try putting "." (the current directory) in your CLASSPATH. I assume you are using the default ("no") package for your classes.

  • Runnable JAR, Main-Class, Class-Path and INDEX.LST

    Some funky finding, don't know whether this is a bug or a feature...
    I'm using
    java version "1.4.2_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
    I observed follwing weired behaviour:
    If you have a JAR packed with your classes and define in the Manifest a Main-Class and a Class-path pointing to JARs in the same directory than the main JAR, example:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
    Main-Class: main.Main
    Class-Path: activation.jar axis.jar commons-discovery.jar
      commons-logging.jar jaxrpc.jar log4j-1.2.8.jar mail.jar saaj.jar wsd
    l4j.jar junit.jarTHEN you should NOT have a META-INF/INDEX.LST file. This file is created for instance by ant jar when setting attribute index="true". Itt complies to the JAR standard and is used to find classes faster.
    If you have such a file then none of the classes of the "Class-Path" JARs will be found. At least that was true for me...
    Hope, I haven't bothered you with something commonly knwown. Just wanted to let you know, to avoid fighting againt JARs like I did for the last 3 hours..damn.
    Cheers,
    Peter

    Does anyone know if having a Class-Path in the manifest would ignore the system environment variable CLASSPATH?
    I'm seeing this in my set-up. I have an external jar file that can be seen if copied to <jre dir>/lib/ext, but when it's in another dir with the CLASSPATH pointing to it can't be found.
    My applet uses a number of jar files and I reference them in the manifest using the Class-Path entry. Does this supercede the environment variable??

Maybe you are looking for

  • How to use OUT variables in my stored procedure

    I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code... CREATE OR REPLACE PROCEDURE testProj.testProcedure (      v_segment_id IN VARCHAR2,      v_student_id OUT VARCHAR2,      v_current_code OUT NUMBER,    

  • Upgrade from 10.1 to 10.2.0.3

    Hi all, We're planing to upgrade from 10.1 to 10.2.0.3 in Windows 2003 SP2, but we don't have the installers. We were browsing on the web and only we found 10.2.0.3 for Windows 2008 and Windows Vista. Can this installer be used to upgrade on Windows

  • ORA-01004: default username feature not supported; logon denied

    I easily connected to oracle table using this password and username in TOAD software. I am using following way to connect to oracle table, but I am getting error 'ORA-01004: default username feature not supported; logon denied' ORA-01004: default use

  • Photoshop elements 12  Installation Failure - Shared Services

    Have tried twice to install (second time switching off my virus checker) get a failure to install shared services then it rolls back and uninstalls the programs. Downloaded Support Advisor - Failed to find any issue. Opened the "PSE12 STI Installer 1

  • Inbound IDOC - for Orders Acknowledgement & Orders change Acknowledgement

    Hi Gurus, Using EDI 855 and 865 need to change delivery date and delivery quantity. The quantities must be equal to the original PO quantities. PO quantity must be splitted to equal the original PO quantity and we need to post the acknowledgements in