• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Package Problem

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Following is my directory structure:
C:\Avinash\Java\mypackage
Under directory mypackage, I have 2 classes namely a & b
Both are in package mypackage
Source Code is as follow:
package mypackage;
public class a {
public static void main(String[] args){
}
}
package mypackage;
public class b extends a{
public static void main(String[] arguments){
}
}
Now when I am compiling class b compiler gives me an error.
It says can not resolve symbol class a
I don't know what is going wrong.
Please explain.
Thanks in advance.
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.
Try this:
1. cd C:\Avinash\Java
2. C:\Avinash\Java>javac -d . A.java
3. //make sure the A.class is in your subdirectory
4. C:\Avinash\Java>javac javac -d . B.java
5. // make sure the B.class is in your subdirectory
5. C:\Avinash\Java>java mypackage.B
 
Avinash Rai
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Charlie,
Classes a & b compiles fine with command -d
But when I run the application from
C:\Avinash\Java\ java mypackage.b
It throws following runtime exception:
"Exception in thread "main" java.lang.NoClassDefFoundError: mypackage/b"
So it still doesn't work.
Anyone any explaination.
By the way which is this command line parameter -b
Are there any other such command line parameters?
Thanks.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
set up your classpath:
c:\set classpath=%classpath%;c:\Avinash\Java;
now try to compile. It should work.

 
Avinash Rai
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone tell me from where I can get information about command line options while compiling Java source files??
Thanks in advance
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Avinash,
Here's a link to the Tool documentation for JDK 1.3 on Sun's site http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Avinash Rai
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jane, Thanks a lot.
 
This is my favorite tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic