Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…

816 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

13 Experts available now in Live!

Get 1:1 Help Now