473,408 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to use class of another java file

11
I have 2 classes saved as 2 different java files.(eg- class ABC.java & PQR.java)

->ABC.java

Expand|Select|Wrap|Line Numbers
  1. classABC extends JTextField
  2. {
  3.     ABC(int i)
  4.     {
  5.     super(i);
  6.     ...
  7.     }
  8.     public ABC()
  9.     {
  10.     ...
  11.     }
  12. }
->PQR.java

Expand|Select|Wrap|Line Numbers
  1. classPQR
  2. {
  3.     ABC a1;
  4.     ABC a2;
  5.      ...
  6.  
  7.    public static main(String[] args)
  8.     {
  9.     ...
  10.     }
  11. }
->Now problem is that HOW CAN I MAKE a1& a2 as objects of class ABC? While compling PQR doesn't find class ABC as it is in another java file. So How can i use a class From ABC. java file in PQR.java
Feb 4 '08 #1
2 4878
BigDaddyLH
1,216 Expert 1GB
It sounds like a classpath issue. If your .java files are in the same directory compile with the command:

Expand|Select|Wrap|Line Numbers
  1. javac -classpath . *.java
the option "-classpath ." tells the compiler to look in the current folder for classes you mention in a .java file.
Feb 4 '08 #2
BigDaddyLH
1,216 Expert 1GB
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Feb 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the...
5
by: S. McKee | last post by:
Hi, I am very (very very) new to java and have what I am sure is a simple problem that I hope someone can help with. I have two .java files. The first has public final class FormatSWN { ...
14
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to...
3
by: ITQUEST | last post by:
The moderator posted this in another thread: (I am starting a new one not to confuse the other subject at hand) ".java classes are compiled to into .class files. If you have a .java file called...
2
by: wolverine | last post by:
Hi, I recently read that every java .class file, is written in a specific binary format. http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html I just want to know whether...
4
by: PaperPilot | last post by:
I have a Java program that is deployed as a .jar file in which is another .jar file with the mysql library. Here is the appropriate section of code: /** * Makes the connection to the...
1
by: sandhyabhavani | last post by:
This article is used to zip a file or directory using vb.net. The classes and method to zip a file is availale in java.io, java.util, java.util.zip class library.To import these you have to add a...
6
by: jmarcrum | last post by:
Hi everyone! I'm using a super class (DVD.java) that handles another class (EnhancedDVD.java). I want to pass the "details" of the DVD into the super class DVD.java. The super class contains the...
19
by: sukatoa | last post by:
I have a class file that instantiates an object from a jar file or simply a class file inside the jar file is used as part of the simple program.... When we use the the jar file in JSP, we...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.