Solved

importing..easy points

Posted on 2004-04-23
10
211 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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 50 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

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
going to wrong jsp page 2 69
Java syntax, or is it Selenium 6 61
Java basic valueOf question 1 50
Java List 4 76
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

739 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