Java .class Questions

Discussion in 'Java' started by Ben, Oct 17, 2004.

  1. Ben

    Ben Guest

    Hello,

    I have a .class file that I need to run, but I don't have access to
    the .java file. My first question is whether I will be able to use
    the functions in this .class file (I'm pretty new to Java and don't
    quite understand the extension system yet).

    My second question is what I have to do in Visual J++ to be able to
    access the functions in this class. Do I have to import it somewhere?
    Or perhaps include it? Or add it as a component for the compiler?

    I'd appreciate any help.

    Thanks,
    Ben
     
    Ben, Oct 17, 2004
    #1
    1. Advertisements

  2. You would most certainly need to know the package structure of the class.
    EG, if the class belonged to package: com.companyname.utils, and the class
    name is CoUtils, then what you could do is create a folder structure
    reflecting the package structure as follows:

    /classes/com/companyname/utils

    put the class in that folder. You can jar it up, or should be able to
    simply add the /classes folder to your classpath. The object that uses the
    compiled class will need to import it as follows:

    import com.companyname.utils.CoUtils;

    you should then be able to reference the methods in CoUtils class.

    NC
     
    Paul & Neelam Checknita, Oct 17, 2004
    #2
    1. Advertisements

  3. Definitely.Make an object of the class and using Reflection API's you
    can list down the functions and make use of them.
    Make sure that the class is in your class path and then you can create
    its instance (for use) by importing the full qualified class name (if
    it exists)
     
    Parvinder Singh Arora, Oct 17, 2004
    #3
  4. Which version? This one?
    <http://msdn.microsoft.com/vjsharp/productinfo/visualj/visualj6/new/default.aspx>
    ...or this one?
    <http://msdn.microsoft.com/vjsharp/productinfo/visualj/visualj11/default.aspx>

    In either case, it seems MS Java tools concentrate on the
    never standard WFC and the obsolete Java 1.1.
    If it is not 1.1, I doubt any MS tool could deal with it.
    I suggest you either..
    a) Ask the supplier of the software.
    b) Dump MS for anything to do with Java and use any of the
    many free Java IDE's available.

    HTH
     
    Andrew Thompson, Oct 17, 2004
    #4
  5. You can use the javap tool to get the member/method declarations of the
    class.
    See <http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javap.html>
     
    Thomas Fritsch, Oct 18, 2004
    #5
  6. You do not need the Java source code for classes in order to use them,
    except inasmuch as the source is the ultimate documentation. A single
    ..class file contains all the bytecode for exactly one class; you can
    compile other classes that depend on it, and if it is an application
    class (has a method "public static void main(String[] args)") then you
    can run it.
    I couldn't say, but if you're going to depend on an IDE to get your work
    done then I'd recommend a more recent one. Since you're just starting
    with Java, though, I would recommend that you use your favorite text
    editor and the command-line tools of a recent Sun Java 2 SDK. Many
    editors will give you syntax highlighting for Java; if yours doesn't
    then you can easily find one that does. The problem with an IDE is that
    if you don't know or understand all the things that it automagically
    does for you, then it can be very confusing and difficult to use.
    Consider, in fact, the question above. Q.E.D.
    Go through Sun's Java Tutorial to get a better foundation in Java:

    http://java.sun.com/docs/books/tutorial/index.html.

    You don't need to do the whole thing to get started; the first few
    "trails" covering the basics will do well to get you going. It's all
    available on-line.


    John Bollinger
     
    John C. Bollinger, Oct 18, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...