The Artima Developer Community
Sponsored Link

Java Answers Forum
Extend from another directory

2 replies on 1 page. Most recent reply: Oct 30, 2003 3:34 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
KevinT

Posts: 24
Nickname: metzedler
Registered: Jun, 2003

Extend from another directory Posted: Oct 30, 2003 1:55 AM
Reply to this message Reply
Advertisement
Could anybody tell me how to extend a class from a directory that is differed from the current one ?

e.g: C:\folder1\super.java and C:\folder2\sub.java

so how to write
public class sub extends ....??


Vu Che

Posts: 8
Nickname: bluegreen
Registered: Oct, 2003

Re: Extend from another directory Posted: Oct 30, 2003 9:23 AM
Reply to this message Reply
you have to import the super class first

import folder1.super;

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Extend from another directory Posted: Oct 30, 2003 3:34 PM
Reply to this message Reply
That's only if the other class is in the package folder1 and if the root of folder1 (in this case C:\) is in the classpath. If the first class is not in any package, you just need to add folder1 itself to the classpath so that it can be found. (In Windows, set classpath=%classpath%;C:\folder1 will do it). Alternatively, (after compiling the base class from its directory) you could compile the derived class from its own directory like this:
c:\folder2> javac -classpath ..\folder1 Sub.java

This way you are telling it where to find the super class. (If you run javac without any parameters, you can see what options is has).

If you don't understand all this classpath stuff, then search this forum and you'll find some explanations.

Flat View: This topic has 2 replies on 1 page
Topic: quick question on main(String[] argv) Previous Topic   Next Topic Topic: LDAP

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use