Cannot acess classes in the same package.

Hi
I have "a.java" in c:/java/test directory. I have "b.java" file in the same directoty which creates a instance of "a" class. "a.java" compiled fine. But when compliling "b.java" i get error message
cannot resolve symbol
symbol : class a
I have used "public" as acess modifier for both the classes. As per rule I can access the classes in the same package. But for some reason my program is not compiling. Can anyone tell me what the acutal problem is.
Thanks in advance.

Javapedia: Classpath
Setting the class path (Windows)
How Classes are Found
java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

Similar Messages

  • Signing 2 different classes in the same package differently.

    I have a class B in the default package.
    I have another class C which is kept in a jar file without any package information. I have signed this jar file in using one alias in my keystore.
    class B instantiates class C and passes its own reference to it.
    When I run class B, i get an error saying,
    Exception in thread "main" java.lang.SecurityException: class "C"'s signer information does not match signer information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(ClassLoader.java:599)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:532)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at B.main(B.java:23)
    Does this mean, I cannot have 2 classes in the same package, signed differently?
    Thanks
    AahRiMaaN

    coupdegrace wrote:
    JoachimSauer wrote:
    Force1 wrote:
    Do the files get automatically compiled if they are in the same package ?No, but if the class you compile depends on another that's not yet been compiled (or for which the source is newer than the .class file), then it will be compiled as well.Like,say If i add a int parameter, amethod(int i),then I will get a error,isn't it ?It actually gives a error.
    Also it will compile automatically only for the first time and any changes made to any file will have to be compiled into latest .class files ?Yes.
    Did compile the files under the above constraints.
    So it is a smooth "run" for the first time,but not after editions to the either files.
    I would appreciate if experts give some feedback on this.
    Thank you.

  • HELP: signer info doesn't match info of other classes in the same package

    I have several jars which need to be signed. They contain several applications and packages which
    are split up based on which parts are needed by server vs client code. How do I get rid of this error?
    I'm signing all the jars using the keytool and jar signer in java 1.3.1. I generate a certificate file.
    My assumption is that each time I sign a different jar, the info is updated in the keystore and
    certificate file. What might I be doing wrong when signing multiple jars?
    (Yes, code from the same package may be in different jars. I don't have any controll of this,
    I'm not in charge of the build and distribution of the various packages).
    Exception in thread "main" java.lang.SecurityException: class
    "com.ibm.ucm.bootup.UCMSysMgtConstants"'s signer information does not match signer
    information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.ibm.ucm.bootup.UCMServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMAdminServerUpdater.<init>(Unknown Source)
    at com.ibm.ucm.bootup.UCMAdminServerUpdater.main(Unknown Source)

    Where you able to solve this issue? (I'm seeing the same problem.)
    Thanks,
    Stacy

  • Accessing other classes in the same package

    I have the following two classes in the same package. Why cant I access the myString vairable from Test2 like I try and do below?
    package test;
    class Test1 {
         public static String myString = "Hello world";
    package test;
    class Test2 {
         static void printMe(){
              System.out.println(Test1.myString);
         public static void main(String args[]) {
                   printMe();
    }

    Why when I take the "package test;" line of code away I can compile it normally?This depends on how you call the compiler and how you have set the class search path. Classes that are in a package are expected to be found from some place in the search path under a directory that has the same name as the package. The default class path consists of only the current directory, ".", so you can avoid all problems by compiling and running from the directory above "test" rather than "test" itself.

  • How does the automatic compilation occur for 2 classes in the same package?

    Hi friends,
    This is my first file Base.java
    package Base;
    class Base {
    protected void amethod() {
    System.out.println("amethod");
    }This is my second file :
    package Class1;
    public class Class1 extends Base {
    public static void main(String argv[]) {
    Base b = new Base();
    b.amethod();
    }However even if I compile only Class1,why do I get the output as "amethod" ? I an not compiling Base class also with this.Do the files get automatically compiled if they are in the same package ?
    Thanks.

    coupdegrace wrote:
    JoachimSauer wrote:
    Force1 wrote:
    Do the files get automatically compiled if they are in the same package ?No, but if the class you compile depends on another that's not yet been compiled (or for which the source is newer than the .class file), then it will be compiled as well.Like,say If i add a int parameter, amethod(int i),then I will get a error,isn't it ?It actually gives a error.
    Also it will compile automatically only for the first time and any changes made to any file will have to be compiled into latest .class files ?Yes.
    Did compile the files under the above constraints.
    So it is a smooth "run" for the first time,but not after editions to the either files.
    I would appreciate if experts give some feedback on this.
    Thank you.

  • Passing a parameter from one class to another class in the same package

    Hi.
    I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
    i. BugWatcherAction.java
    ii.BugWatcherRefreshAction.Java.
    We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
    So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
    ==============================================================
    public Object loadContent() throws Exception {
    Hashtable htStore = new Hashtable();
    JetspeedRunData rundata = this.getInputData();
    String pId = this.getPorletId();
    PortalLogger.logDebug(" in the portlet content: "+pId);
    pId1=pId;//done by sraha
    htStore.put("PortletId", pId);
    htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
    htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
    HttpServletRequest request = rundata.getRequest();
    PortalLogger.logDebug(
    "BugWatcherPortletContent:: build normal context");
    HttpSession session = null;
    int bugProfileId = 0;
    Hashtable bugProfiles = null;
    Hashtable bugData = null;
    boolean fetchProfiles = false;
    try {
    session = request.getSession(true);
    // Attempting to get the profiles from the session.
    //If the profiles are not present in the session, then they would have to be
    // obtained from the database.
    bugProfiles = (Hashtable) session.getAttribute("Profiles");
    //Getting the selected bug profile id.
    String bugProfileIdObj = request.getParameter("bugProfile" + pId);
    // Getting the logged in user
    String userId = request.getRemoteUser();
    if (bugProfiles == null) {
    fetchProfiles = true;
    if (bugProfileIdObj == null) {
    // setting the bugprofile id as -1 indicates "all profiles" is selected
    bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
    if (bugProfileIdObj == null) {
    bugProfileId = -1;
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    session.setAttribute(
    ("bugProfileId" + pId),
    Integer.toString(bugProfileId));
    //fetching the bug list
    bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
    PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
    if (bugData != null) {
    Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
    } else {
    htStore.put("NoProfiles", "Y");
    } catch (CodedPortalException e) {
    htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    PortalLogger.logException
    ("BugWatcherPortletContent:: CodedPortalException!!",e);
    } catch (Exception e) {
    PortalLogger.logException(
    "BugWatcherPortletContent::Generic Exception!!",e);
    htStore.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
    if (fetchProfiles) {
    bugProfiles = (Hashtable) bugData.get("Profiles");
    session.setAttribute("Profiles", bugProfiles);
    // putting the stuff in the context
    htStore.put("Profiles", bugProfiles);
    htStore.put("SelectedProfile", new Integer(bugProfileId));
    htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
    return htStore;
    =============================================================
    And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
    In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
    =============================================================
    public void doPerform(RunData rundata, Context context,String str) throws Exception {
    JetspeedRunData data = (JetspeedRunData) rundata;
    HttpServletRequest request = null;
    //PortletConfig pc = portlet.getPortletConfig();
    //String userId = request.getRemoteUser();
    /*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
    String pId = request.getParameter("PortletId");
    PortalLogger.logDebug("just after pId " +pId);  */
    //Calling the variable holding the value of portlet id from BugWatcherAction.java
    //We are getting the portlet id here , through a variable from BugWatcherAction.java
    /*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
    String portletID = bgAct.pId1;
    PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
    // updating the bug groups
    Hashtable result = new Hashtable();
    try {
    request = data.getRequest();
    String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
    //String pId = (String)request.getParameter("portletId");
    //String pId = pc.getPorletId();
    PortalLogger.logDebug("just after pId " +pId);
    PortalLogger.logDebug("after getting the pId-----sraha");
    result =BugWatcherAPI.getbugList(profileId, userId);
    PortalLogger.logDebug("select the new bug groups:: select is done ");
    context.put("SelectedbugGroups", profileId);
    //start clearing the cache
    ContentCacheContext cacheContext = getCacheContext(rundata);
    PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
    // remove the markup content from cache.
    PortletContentCache.removeContent(cacheContext);
    PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
    //remove the backend content from cache
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
    PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
    PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
    if (pdata != null)
    // User's data found in cache!
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
    pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
    PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
    //end clearing the cache
    // after clearing the caching calling the data from the database taking a fn from the portletContent.java
    PortalLogger.logDebug("after clearing cache---sraha");
    BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
    Hashtable httable= new Hashtable();
    httable=(Hashtable)bugwatchportcont.loadContent();
    PortalLogger.logDebug("after making the type casting-----sraha");
    Set storeKeySet = httable.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, httable.get(paramName));
    PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
    } catch (CodedPortalException e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    catch (Exception e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
    try {
    ((JetspeedRunData) data).setCustomized(null);
    if (((JetspeedRunData) data).getCustomized() == null)
    ActionLoader.getInstance().exec(data,"controls.EndCustomize");
    catch (Exception e)
    PortalLogger.logException("bugwatcherRefreshAction", e);
    ===============================================================
    In the bugwatcher Action there is another function called PostLoadContent.java
    here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
    ================================================
    // Get the PortletData object from intermediate store.
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
    //rundata.getRequest().getRemoteUser()));
    ((JetspeedUser)rundata.getUser()).getUserName()));
    pId1 = (String)portlet.getID();
    PortalLogger.logDebug("in the bugwatcher action:"+pId1);
    try {
    Hashtable htStore = null;
    // if PortletData is available in store, get current portlet's data from it.
    if (pdata != null) {
    htStore =(Hashtable) pdata.getObject(     PortletCacheHelper.getUserPortletHandle(
    ((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
    //Loop through the hashtable and put its elements in context
    Set storeKeySet = htStore.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, htStore.get(paramName));
    bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
    bRefAc.doPerform(pdata,context,pId1);
    =============================================================
    So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
    I am unable to implement that thing.
    If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
    Please let me know as early as possible.
    Thanks and regards,
    Santanu Raha.

    Have you run it in a debugger? That will show you exactly what is happening and why.

  • How to comunicate two class in the same package

    I HAVE SET MY CLASSPATH as /home/shadab/program/java/MyPack in CLASSPATH environment variable.
    below is a super class java file Protection.java
    I also compiled it successfully using javac Protection.java
    package MyPack;
    public class Protection {
    int n = 1;
    private int n_pri = 2;
    protected int n_pro = 3;
    public int n_pub = 4;
    public Protection() {
    System.out.println("base constructor ");
    System.out.println("n = " + n);
    System.out.println("n_pri = " + n_pri);
    System.out.println("n_pro = " + n_pro);
    System.out.println("n_pub = " + n_pub);
    Below is subclass of superclass
    package Mypack;
    class Derived extends Protection {
    Derived() {
    System.out.println("Derived constructor ");
    System.out.println("n = " +n);
    // System.out.println("n_pri = " + n_pri);
    System.out.println("n_pro = " + n_pro);
    System.out.println("n_pub = " + n_pub);
    while i compiled subclass
    javac Derived.java
    following error occured
    Derived.java:3: cannot find symbol
    symbol: class Protection
    class Derived extends Protection {
    ^
    Derived.java:8: cannot find symbol
    symbol : variable n
    location: class Mypack.Derived
    System.out.println("n = " +n);
    ^
    Derived.java:11: cannot find symbol
    symbol : variable n_pro
    location: class Mypack.Derived
    System.out.println("n_pro = " + n_pro);
    ^
    Derived.java:12: cannot find symbol
    symbol : variable n_pub
    location: class Mypack.Derived
    System.out.println("n_pub = " + n_pub);
    PLEASE HELP ME TO SOLVE THIS PROBLEM ..

    1. To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    2. Read this page:
    [http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]
    3. I advise that you don't use the CLASSPATH environment variable. Instead, use the -classpath or -cp flag when compiling/running.
    4. The package root must be available on the classpath. Since your classes are in the package MyPack and in the folder /home/shadab/program/java/MyPack, that means that /home/shadab/program/java must be on the classpath.
    db

  • Trying to access a private attribute of a class in the same package

    Hi,
    I have defined a private attribute in a class
    class Sample {
         private String newString = "hello";
    in another class I am trying to access newString attribute using reflection api. It is throwing hte following exception
    java.lang.NoSuchFieldException: value
         at java.lang.Class.getDeclaredField(Unknown Source)
         at refletionpack.mainclass.main(mainclass.java:20)
    any ideas how to do it exactly? Should stringclass.getDeclaredField("value")
    have the field name(newString) as a parameter?
    public class mainclass {
         static Class stringclass = Sample.class;
         static Field stringCharsField = null;
         public static void main(String args[]){
              try{
                   stringCharsField = stringclass.getDeclaredField("value");
                   stringCharsField.setAccessible(true);
                   char[] stringChars = (char[])stringCharsField.get("newString");
                   System.out.println(stringChars);
              }catch(NoSuchFieldException ex){
                   ex.printStackTrace();     
              }catch(IllegalAccessException ex){
                   ex.printStackTrace();     
    }

    Hi,
    to obtain the value of your private attribute you have to change two lines of code. At first you have to tell your class and not the field that private attributes can be accessed by using stringClass.setAccessible(true);After that you have to specify the name of the attribute to obtain which is called newString in your class which results in
    stringCharsField = stringClass.getDeclaredField("newString");For the invocation of the method get(Object) you need an object first that is an instance of the analyzed class by calling Object sample = stringClass.newInstance.
    Then you can retrieve the actual data of the requested field by calling String string = (String) stringCharsField.get(sample);A simpler solution would be when you make your attribute newString static. Then you can omit the necessary object for the retrieval of the attribute data and the line would result in String string = (String) stringCharsField.get(null);.
    For further issues considering reflection you should read the appropriate API.
    Hope it helps.

  • How to retrieve hashmap Values in other class within the same package.

    I have created two class ie A and B.
    In A class I have created one hashmap and stored some keys and values.
    But i want to retrieve that values in class B.
    So can any one can give any code ,so that i will try on Eclipse IDE

    Maybe anything. I'm not that interested. It's Java programming 101, about 10 minutes into the first class.

  • Calling a method of one class from another withing the same package

    hi,
    i've some problem in calling a method of one class from another class within the same package.
    for eg. if in Package mypack. i'm having 2 files, f1 and f2. i would like to call a method of f2 from f1(f1 is a servlet) . i donno exactly how to instantiate the object for f2. can anybody please help me in this regard.
    Thank u in advance.
    Regards,
    Fazli

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Inheritance class in the system package

    Hi all, when I use a tool such as Java Decompiler to explore the classses in the system package(javax.microedition.lcdui provided with Nokia SDK_v1_1), I see that there are many non-documented methods in the class, e.g, getkeyPressedEvent() in the class TextBox. So I try to override these methods in the sub-classes that are declared in the same package. Compiling by J2SDK 1.4.1_03 is OK but running on the Nokia simulator 6310i, I take the error msg: "Cannot create class in the system package".
    What is wrong here? Does it means we can not modify the code of the super class in the system package?
    Please help me

    What is wrong here? Does it means we can not modify
    the code of the super class in the system package?Exactly.
    It would violate the license.

  • Running file in the same package problem

    I have 2 java file packed in the same package:
    DBConnection.classpackage main;
    import java.sql.*;
    public class DBConnection {
    }t1.class
    package main;
    import main.DBConnection;
    import java.util.ArrayList;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.sql.*;
    public class t1 {
    }They are packed in the same directory, the path is:
    D:\java\project1\main\DBConnection.class
    D:\java\project1\main\t1.class
    When i was in command prompt (window), I tried both of these but encounterd the following error
    D:\java\project1\main>java t1
    D:\java\project1\main>java -cp D:\java\project1\main t1
    I encountered the following errors:
    Exception in thread "main" java.lang.NoClassDefFoundError: t1 (wrong name: main/t1)
    When I tried:
    D:\java\project1\main>java -cp D:\java\project1 t1
    I got this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: t1
    Can anyone tell me the reason? Thx.

    package main;
    import main.DBConnection;You don't need to import a class in the same package.

  • Cannot resolve symbol when the classes are in the same package

    i have one interface and two classes all in the same package. am getting " cannot resolve symbol", when the code refers to the interface or the class .
    the package name is collections.impl and
    the directory i used to store all the java files:
    c:\jdk\bin\collections\impl.
    isthere any othe option other than compiling all the files from the comand line at the same time?
    please help - i m new to java.

    If you have:
    I.java:
    package some;
    public interface I {
        void method();
    }A.java:
    package some;
    public class A implements I {
        public void method() {
            new B();
    }B.java:
    package some;
    public class B implements I {
        public void method() {
            new A();
    }in c:/temp/some for example
    you can compile your files with
    javac c:/temp/some/*.java
    It seems that you have errors in your code.
    Recheck it twice or use NetBeans IDE(http://www.netbeans.org) it will do this for you ;)

  • How to convert the class in the one package to same class in the other pack

    How to convert the class in the one package to same class in the other package
    example:
    BeanDTO.java
    package cho3.hello.bean;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    BeanDTO.java in other package
    package ch03.hello;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    My converter lass lokks like
    public class BeanUtilTest {
         public static void main(String[] args) {
              try
                   ch03.hello.BeanDTO bean=new ch03.hello.BeanDTO();
              bean.setAge(10);
              bean.setName("mahesh");
              cho3.hello.bean.BeanDTO beanDto=new cho3.hello.bean.BeanDTO();
              ClassConverter classconv=new ClassConverter();
              //classconv.
              System.out.println("hi "+beanDto.getClass().toString());
              System.out.println("hi helli "+bean.toString()+" "+bean.getAge()+" "+bean.getName()+" "+bean.getClass());
              Object b=classconv.convert(beanDto.getClass(),(Object)bean);
              System.out.println(b.toString());
              beanDto= (cho3.hello.bean.BeanDTO)b;
              System.out.println(" "+beanDto.getAge()+" "+beanDto.getName() );
              }catch(Exception e)
                   e.printStackTrace();
    But its giving class cast exception. Please help on this..

    Do you mean "two different layers" as in separate JVMs or "two different layers" as in functional areas running within the same JVM.
    In either case, if the first class is actually semantically and functionally the same as the second (and they are always intended to be the same) then import and and use the first class in place of the second. That's beyond any question of how to get the data of the first into the second if and when you need to.
    Once you make the breakthrough and use one class instead of two I'd guess that almost solves your problem. But if you want to describe your architecture a little that would help others pin down want you're trying to do.

  • Problem in package and accessing classes in the same directory

    i have a class JApplet1 which calls other classes from the same directory.ALL the other classes have a main within them whereas JApplet1 has an init method within it...the problem is this JApplet1 class is not able to call the other classes. there r no compile time errors but at runtime the classes are not being called...what should i do....suggestions plz..

    What exception are you getting?

Maybe you are looking for

  • How to use a ASUS CD to burn pic

    Hello I hace an ASUS 08D2S-U  not great so far !  i just cannot find how to burn a pic to the CD from my pictures, hope someone knows I have come close but a windows says : do you really want to burn a blanck CD to an other CD ?? lol  I have OSX mave

  • Error: ORA-12008: error in materialized view refresh path

    Hello Dba' s We are on 12.0.6 EBS with 10.2.0.5 DB on Sun solaris SPARC 64 bit. We are getting below error while Refreshing Materialized View. Start of log messages from FND_FILE Error: ORA-12008: error in materialized view refresh path ORA-00600: in

  • How to prepare for SCJP1.5

    Hi All, I want to do SCJP1.5 certification. Please suggest me , how to prepare for that Text Books Mock Test links , I got mostly mock test for SCJP1.4

  • EbXml problem - Trading Partner Tutorial

    I ran across a problem trying to learn how to use ebXml in a business process. Has anyone else noticed this problem. I've tried it several times scratch and get the same result. In the tutorial you create 2 business processes a seller process and a b

  • Read-only root, initialising random seed fails

    I have moved my HTPC installation to an SDHC card, with read-only root and /home and /var mounted to tmpfs. it boots up just fine, Xbmc runs like it's supposed to, but "Initialising random seed reports [FAILED]". The bug report on things stopping a r