Java .class Questions

B

Ben

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
 
P

Paul & Neelam Checknita

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
 
P

Parvinder Singh Arora

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).

Definitely.Make an object of the class and using Reflection API's you
can list down the functions and make use of them.
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?

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)
 
A

Andrew Thompson

My second question is what I have to do in Visual J++

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.
..to be able to
access the functions in this class.

If it is not 1.1, I doubt any MS tool could deal with it.
..Do I have to import it somewhere?
Or perhaps include it? Or add it as a component for the compiler?

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
 
T

Thomas Fritsch

Ben said:
Hello, 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

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

John C. Bollinger

Ben said:
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).

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.
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 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.
I'd appreciate any help.

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
(e-mail address removed)
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top