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
Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 “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 the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

790 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