Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

importing..easy points

Posted on 2004-04-23
10
Medium Priority
?
221 Views
Last Modified: 2010-03-31
Hello,
I'm using Jdev.

I have two projects and one workspace

Workspace
   -project1
      -myClassA.class
   -project2
      -myClassB.java
      -myClassB.class


I want to import myClassA into myClassB

can anyone give me the line of code to do that please?
Ghost
0
Comment
Question by:copyPasteGhost
[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
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899655
keep your classpath upto "workspace"

// if you want you myClassA in myClassB then add the following in the top of myClassB.java

import project1.*;


// if you want you myClassB in myClassA then add the following in the top of myClassA.java

import project2.*
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899658
in myClassB.java

import  x.y.z.myClassA;


with x.y.z the "package path"
0
 
LVL 13

Author Comment

by:copyPasteGhost
ID: 10900308
that didn't work..
I have this set up

Workspace
   -project1
      -com
         -mypack1
            -myClassA.class
   -project2
      -com
         -mypack1
            -myClassB.class
            -myClassB.java
I get this error..

Error(20,1): cannot access directory project1.com.mypack1; verify that directory is reachable from classpath and/or sourcepath

from myClassB.java
import project1.com.mypack1*;

thanks,
Ghost
0
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!

 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10900367
write a own batch file like..named it as compile.bat

javac -classpath C:\\..project1\com\mypack1;  myClassA.java myClassB.java

from the command prompt type compile.bat thats all...it will compile all the specified .java files

and run it later...

all the best...

R.K.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900437
if both classes are in mypack1 then there's no need for an import.

just ensure both .java files contain

package mypack1;

as the first line

0
 
LVL 13

Author Comment

by:copyPasteGhost
ID: 10900601
they aren't..

one is from project 1 and the other is from project 2...
see what I"m saying?
Ghost
0
 
LVL 13

Author Comment

by:copyPasteGhost
ID: 10900769
>rama_krishna580
dude I have no idea what you are saying.. but it looks good :)
can you explain a bit more please?
Ghost
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 10905333
assuming both are in package com.mypack1 then add the follwoing directories to your classpath:
..../project1
..../project2

no need for an import because they are both in the same package.

If this is not the case can you tell us what packjage they are in exactly.
0
 
LVL 13

Author Comment

by:copyPasteGhost
ID: 10907231
well it turns out that Jdev has this feature to add additional class paths. once I put in the path to the floder ie..
project1.com.mypack1, the class was found and I was able to import it without a problem.

>>no need for an import because they are both in the same package.

I needed an import cause the even though the packages had the same name they were not the same package..if you notice my directory diagram above you will see this to be the case.

Nevertheless, Thanks Objects for the tip,
Ghost
0
 
LVL 92

Expert Comment

by:objects
ID: 10909571
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

670 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