Solved

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

Posted on 2001-09-09
4
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 64
ejb mdb examples 1 21
how to debug htl and js pages 8 57
Java class and jar 3 42
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

733 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