Java Question

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Java Question

  1. #1
    Steve Cimino Guest

    Default Java Question

    I&#039m building a COM object in Java. Now, I understand the concept of inheritance, so that every time I make an instance of the class, all inherited values come with the class.<BR><BR>In my Class, I have one public function. However, when calling this DLL from ASP (in Visual Interdev), the available methods such as notify() and notifyall() are being exposed (among about 6 others such as hashCode() and wait()). From the documentation I read, this is due to the inheritance of this class being exposed.<BR><BR>I&#039m not concerned with managing threads at this point, so how do I hide this? Isn&#039t this breaking the rule of encapsulation? For me, it&#039s not a big deal, but I don&#039t want to confuse the other programmers when I issue this dll out to them.<BR><BR>Forgive me for being a green Java guy (Personal apology to you, Shai)

  2. #2
    Shedao Shai Guest

    Default RE: Java Question

    Why apologize? I am still learning to this day also. Actually that&#039s what I&#039m doing at this very moment so you caught me at a good time with Java fresh in my mind. In your subclass simply override the methods you dont want users to see and make them private like so:<BR><BR>private void fooMethod(){<BR>//generic code or no code at all, doesn&#039t matter<BR>}<BR><BR>Another technique would be to define them as private in the superclass. Im not sure if that will fit your situation but the subclass will only inherit public methods. That would probably be more appropriate:<BR><BR><BR>Let me know if this helps :-)

  3. #3
    Steve Cimino Guest

    Default Protected, of course

    I attempted to override the method (I&#039m using Visual J++), and it comes back as protected. When I try and change this to private (for instance, clone()), I get the error:<BR><BR>Attempt to reduce access level of member &#039Object Object.clone()&#039 (J0062)<BR><BR>Finding the superclass (which is java.lang.Object), it&#039s not letting me access into the class to actually try and alter these (and I&#039m not sure this is such a good idea. No telling what the compiler will whine about next)<BR><BR>I&#039m having a hell of a time with this... I&#039ve searched Sun&#039s site yesterday for an answer. They&#039re kinda like MS, aren&#039t they? Speaking of which, do you know of/have a web site that lists all the available header files (or whatever Java refers to them in their import)? I was looking for the ADO object, and finally found it. But for future reference, do you know of the site that lists these all out for you?<BR><BR>I was apologising because I thought you were the Java Guru. I worked with your tutorial the other day, and thought you were the man with this language.

  4. #4
    Steve Cimino Guest

    Default The unfortunate answer

    Your classes may want to override the following Object methods. The equals/hashCode are listed together as they must be overridden together. <BR><BR>clone <BR>equals/hashCode <BR>finalize <BR>toString <BR><BR>Your class cannot override these Object methods (they are final): <BR>getClass <BR>notify <BR>notifyAll <BR>wait <BR><BR>Found this at your website you sent me, different page:<BR><BR><BR>Nice tutorials. Looks like I&#039ll be living there for the next few days.<BR><BR>Now I know why everyone likes to stick with VB COM!!!!

  5. #5
    Join Date
    Dec 1969
    Los Angeles, CA

    Default GO VB COM.....GO VB COM......

    i dont even KNOW how to tool around with JAva and all that fancy stuff

  6. #6
    Steve Cimino Guest

    Default Well, since I don't have a Linux box to play w

    I&#039m not exactly sure if VB COM will port over (we have a possibility with a "merged" company to support some website stuff). I figured I might as well start making the COM objects in Java, due to it&#039s cross platform capability. I&#039ve got the syntax down flat, but it&#039s the setup of all it&#039s classes and how to expose interfaces correctly (not too mention thread management) that&#039s tough at first.<BR><BR>Everyone knows how to set a database connection in VB/VBScript. Just a little different this way.<BR><BR>Although I wonder if I&#039m doing this all for naught. After bringing up my desire to switch all COM to Java over the next few months, I got this email from someone who found this on the web:<BR><BR>Open and Independent<BR>ActiveX relies on an open industry protocol as the basis for its cross-machine infrastructure standards, and it is language- and tool-independent. For example, COM uses the Open Software Foundation&#039s (OSF) DCE Remote Procedure Call (RPC), so tool vendors other than Microsoft can use this technology. You don&#039t have to use Microsoft tools to create ActiveX objects (of course, I wouldn&#039t object if you did). You aren&#039t limited to Windows as your operating system, either: ActiveX is a cross-platform solution that will work on many of the popular systems including Unix, your Macintosh, Windows 95 and Windows NT 4.0, and even on Windows NT 3.51 and Windows 3.1. You aren&#039t limited to C as your language of choice; COM objects are supported in a variety of languages, including Java, Visual C, Visual BasicĀ®, PASCAL, and (gasp!) COBOL !<BR><BR>

  7. #7
    Shedao Shai Guest

    Default RE: Well, since I don't have a Linux box to pl

    Well, not the man. And I am a pure java man. Never used it with COM interfaces before. I use servlets/jsp/beans to accomplish the same thing I could use COM/asp for on a NT box.<BR><BR><BR>I thought you were inheriting from a superclass that you created.<BR>Maybe an abstract class. Wasn&#039t sure. But overriding a base class&#039 methods is not possible. <BR><BR><BR>IMHO If you want true cross platform software you should use straight java. I can write an app that works on my NT dev box, send it out to my linux server to test further, then deploy to a sparc. That is cross platform. <BR><BR>Oh - one thing about Java - configuration is the most important and usually most difficult part

  8. #8
    Join Date
    Dec 1969

    Default Just another tool in the toolbox

    Java&#039s just another tool in the toolbox. Its got a lot to offer though.<BR><BR><BR>VB is great for what it&#039s meant to accomplish - write apps quickly. I don&#039t go out of my way to use it, but if I needed to pump out a DB object that parses XML on a NT box quickly, I would immediately think VB.

  9. #9
    Steve Cimino Guest

    Default So no cream and sugar?

    Forgive me for sounding silly, but I thought that this was pure Java. I mean, it may be Microsoft&#039s baby (J++), but it shouldn&#039t be all that different.<BR><BR>Servlets/beans... I&#039ve only heard of them. Haven&#039t done too much research into them yet. Right now, I&#039m just concerened about ASP/COM communicating to a DB and a VAX. What&#039s scary is, that I wasn&#039t sure that Linux would port a VB COM object, so I thought start now with other solutions.<BR><BR>So what you&#039re saying, is that in "pure" Java, you don&#039t need the virtual machine? That&#039s the only thing I can think of that would be truly "plug and play cross platform", but to the best of my (little) knowledge, Java always needs the VM.

  10. #10
    Shedao Shai Guest

    Default RE: So no cream and sugar?

    What I was saying was I&#039m not familiar with developing COM objects using Java, meaning they implement COM interfaces like IDispatch, IUknown, etc. I&#039ve never done it. When I said "Pure Java" I simply meant no COM interface.<BR><BR><BR><BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts