• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

compilation problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to compile some java files which uses the object of some other class. For example, i have two directories 'comm' and 'b'. i am trying to compile the java files in directory 'b' which uses the files in 'comm' directory.
I " don't " want to import the package of 'comm', but i want the java files in 'b' should get compiled without error. the files in 'b' do not conatain error. but every time i compile it. it gives me some object is missing(which is in 'comm'). how do i do it?
please help me with this
 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
package seet1;
public class aa
{public void aab()
{ System.out.println("AAAAAAAA");
}
}
package seet2;
public class bb
{public void bbbb()
{System.out.println("BBBBBBBBBBBBBBBB");
}
}
public class cc
{public static void main(String args[])
{seet1.aa aa1= new seet1.aa();
aa1.aab();
System.out.println("in AAA");
seet2.bb bb1 = new seet2.bb();
bb1.bbbb();
System.out.println("in BBBB");
}
}
HTH,
Seetesh
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds like you are having a problem with your CLASSPATH. Make sure that the parent directory of your "comm" and "b" directories is in the CLASSPATH. For example, if your directory structure looks like this:
...
MyProject
\--src
|--comm
|--b
then make sure MyProject/src is in your CLASSPATH. This also assumes that your classes are declared in packages, e.g. "package comm;" appears in all of your comm classes and "package b;" appears in all of your b classes.
 
prachi jahagirdar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the answers.
What I have stated down is possible
when we give command as
javac -classpath \MyProject\src\comm \Myproject\src\b\test.java
then does the '-classpath' calls the setclasspath and sets the path to the specified directory. If yes then is previously set path gets reset?
 
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic