• 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

How to set classpath

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Super.java
----------
package p1;
public class Super
{
public void print()
{
System.out.print("Super");
}
}
=======================
Sub.java
--------
import p1.*;
class Sub
{
public static void main(String a[])
{
new Super().print();
}
}

i compile the the Super.java file and create the package p1. then i compile the Sub.java file in same location it gives an error message like

E:\JSF>javac Sub.java
Sub.java:6: cannot access Super
bad class file: .\Super.java
file does not contain class Super
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
new Super().print();
^
1 error

who can i solve this problem
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

Did you put the compiled file Super.class inside the p1 directory?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See if THIS helps. At step 3 it introduces a directory structure that matches the package structure. That's the most natural way to set things up.
 
I am displeased. You are no longer allowed to read this 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