Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-21-2005, 10:38 AM   #1
Registered: Sep 2004
Location: Laredo, TX
Distribution: Slackware 11.0 [both lap & pc] WinXP
Posts: 164

Rep: Reputation: 30
Java Question on using your own class

well we came up with a simple class, and we where trying to use it, but when trying to import
import wintersclass;
public class usingwintersclassmainprogram
it wont compile, something that worked was just call out the class inside the program
public static void main(String[] args) throws IOException
wintersclass testName;
testName = new wintersclass();
im wondering how can i call out the class to import at the very top
Old 01-21-2005, 11:00 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
You only need to import a class if it's defined in a different package (i.e. subdirectory) than the class you are using. Javac will automatically search for classes in the class path when trying to resolve symbol names.

Try removing the
import wintersclass;
line from the top of the file. If that doesn't work, please post the error message that you are getting when you compile.
Old 01-22-2005, 10:11 AM   #3
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

Rep: Reputation: 30
Just a tip, but when you instantiate your object:

wintersclass testName;  
testName = new wintersclass();
You could just do this:

wintersclass testName = new wintersclass();


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
java tree class true_atlantis Programming 1 08-30-2005 12:03 PM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
Compile Java - .class, .java, .jar ? woranl Programming 2 11-09-2004 10:12 PM
JAVA : cannot find class JFrame? OmniXBro Programming 11 06-04-2004 02:53 AM
Java: Can't remember class coolman0stress Programming 0 11-04-2003 07:08 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration