Solved

how to import self-created class in different package in JBuilder4

Posted on 2001-09-09
4
222 Views
Last Modified: 2011-04-14
I need to run this program in Jbuilder4.
I want use MyInput class in my ComputeArea.java .
I create MyUtilities.jpr, MyInput.java belongs to this project and  is saved on my computer as c:\WINDOWS\jbproject\MyUtilities\MyInput.java. The first line in the file is: package MyUtilities;)  
  What would be the import command in ComputeArea.java  which locate in a different project chapter2.jpr, such as: c:\WINDOWS\jbproject\chapter2\ComputeArea.java (The first line in this file is: package chapter2;
What should be the import statement in the computeArea.java, should it be :
import MyUtilities.MyInput;  ?
But when I try this, it tell me MyInput class was not found.
Thank you very much for your time.
0
Comment
Question by:minmin
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6469563
> import MyUtilities.MyInput;

This is correct.
You need to ensure that the directory c:\WINDOWS\jbproject is in your classpath.
0
 
LVL 92

Expert Comment

by:objects
ID: 6469564
Is MyInput.class in the same directory as MyInput.java?
0
 
LVL 3

Accepted Solution

by:
dnoelpp earned 100 total points
ID: 6469784
You have two different JBuilder projects, right?

Then most probably the classes are compiled to different directories as say:

project 1: c:\WINDOWS\jbproject\MyUtilities\classes
project 2: c:\WINDOWS\jbproject\chapter2\classes

That's why when you compile the project MyUtilities, it doesn't find the classes in chapter2.

You have several possibilities to solve this problem:

1. Change the output directory of one of the projects to the same output directory. I do that often: All projects have the same output directory.

2. Change the library settings of one of the projects (right click on the project icon and select ...) to contain the output directory of the other project as well.
0
 

Author Comment

by:minmin
ID: 6473061
Thank you so much. I did it follow your instruction, and it works!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now