LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-21-2005, 10:38 AM   #1
k1ll3r_x
Member
 
Registered: Sep 2004
Location: Laredo, TX
Distribution: Debian 11
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
Code:
import wintersclass;
import java.io.*;
public class usingwintersclassmainprogram
{
...
it wont compile, something that worked was just call out the class inside the program
Code:
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
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

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
Code:
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
darkRoom
Member
 
Registered: Mar 2004
Location: Valencia, espaņa
Distribution: Slack, Gentoo, Custom
Posts: 162

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

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

Code:
wintersclass testName = new wintersclass();
 
  


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:21 AM.

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