Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Really Basic Question
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
copthesaint




PostPosted: Thu Apr 14, 2011 10:46 am   Post subject: Really Basic Question

Alright, so I have never done this since I havnt made a large project like I am now, but how do you specify an objects path when using it in your class? Say for example I have a class in a folder and another outside of it. Could I get an example of how to call the class for an object? Just for example say I have a Box class and a Circle class Razz
 
Sponsor
Sponsor
Sponsor
sponsor
2goto1




PostPosted: Thu Apr 14, 2011 10:58 am   Post subject: Re: Really Basic Question

It sounds like Java packages and imports are what you're looking for. See the "Packages" trail in the Java Tutorials, http://download.oracle.com/javase/tutorial/java/package/index.html.
 
apython1992




PostPosted: Thu Apr 14, 2011 10:58 am   Post subject: RE:Really Basic Question

Are you talking about having classes saved as separate source files in the project folder, and importing the classes?
 
DemonWasp




PostPosted: Thu Apr 14, 2011 11:02 am   Post subject: RE:Really Basic Question

You have to make sure that all the code you're referencing is on the almighty "classpath". This is the series of locations that the JVM will look to find something that looks like your class. The default classpath includes all the standard Java API, plus the current directory. You will need to add the directory containing the relevant .class files.

You can read a really good explanation of how you should set things up on the relevant Wikipedia page: http://en.wikipedia.org/wiki/Classpath_(Java)

You don't have to do anything special in your Java code to handle the paths. You just have to say which classes you want, and the JVM will ask the classpath where to find those classes.
 
copthesaint




PostPosted: Fri Apr 15, 2011 9:20 am   Post subject: RE:Really Basic Question

thanks people Smile Ill look at these.
 
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: