Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Import non-packaged class

Thread view: 
nivanson@gmail.com - 01 Oct 2006 16:20 GMT
Hi, I wonder if it's possible to package a .class file so that I can
import it from outside default package. It seems to me that you cannot
import classes in default package if you are not working in default
package.

So.
Is it possible to package a class that I don't have access to the
sourcecode to (it's not packaged at all...) so that I can access it
from outside default package and how do I do it?

Thanks!
Arne Vajhøj - 01 Oct 2006 16:23 GMT
> Hi, I wonder if it's possible to package a .class file so that I can
> import it from outside default package. It seems to me that you cannot
[quoted text clipped - 5 lines]
> sourcecode to (it's not packaged at all...) so that I can access it
> from outside default package and how do I do it?

I don't think you can.

Which is a very good reason for always using packages !

As a workaround, then maybe you can use some reflection.

Arne
nivanson - 01 Oct 2006 16:33 GMT
Right...

We are using this file Prompt.class in class for console inputs with
validations of input types. I guess I'll stick with the Scanner for
now! We have no way of finding the sourcecode for this class since he
got it from some guy on a university. :S

Thanks

> > Hi, I wonder if it's possible to package a .class file so that I can
> > import it from outside default package. It seems to me that you cannot
[quoted text clipped - 13 lines]
>
> Arne
Arne Vajhøj - 01 Oct 2006 16:49 GMT
> We are using this file Prompt.class in class for console inputs with
> validations of input types. I guess I'll stick with the Scanner for
> now! We have no way of finding the sourcecode for this class since he
> got it from some guy on a university. :S

I would always prefer an official Java API class over
some code from the net.

Especially if the code from the net comes without
packages, because that does not imply good quality.

Arne

PS: If you have sufficient license rights to the code you
    could decompile it, add package and recompile.
nivanson - 01 Oct 2006 17:03 GMT
> > We are using this file Prompt.class in class for console inputs with
> > validations of input types. I guess I'll stick with the Scanner for
[quoted text clipped - 11 lines]
> PS: If you have sufficient license rights to the code you
>      could decompile it, add package and recompile.

It isn't good quality. -..- It even mixes swedish and english naming in
it's functions. Though it has some obvious advantages over the Scanner
that we also got introduced to. Sooner in our course we will write our
own input libraries I think... Or start using Swing or SWT (or qt4 if
my suggestion passes).

Thanks for answering my question! I'll try the decompiler for fun ^^


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.