Solved

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

Posted on 2001-09-09
4
225 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 119
@SBGen Method 3 36
Java Options in Zimbra Server 2 44
diffSum example 4 23
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

912 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

21 Experts available now in Live!

Get 1:1 Help Now