importing and using .class file

R

Raous

I have a .class file, not a .java file.

After I imported it to my Eclipse Project,
I had no idea to use it.

I put

import foo;

but eclipse doesn't recognize 'foo' as a class name.

How can I use a .class file?
Do I need its source file?
 
M

Michael Redlich

Raous said:
I have a .class file, not a .java file.

After I imported it to my Eclipse Project,
I had no idea to use it.

I put

import foo;

but eclipse doesn't recognize 'foo' as a class name.

How can I use a .class file?
Do I need its source file?

Hi Raous:

foo.class is the resulting bytecode from successful compiling foo.java.
You need a Java Virtual Machine (JVM) to execute foo.class. For
example:

C:\> javac foo.java

will generate foo.class assuming that everything successfully compiles.

C:\> java foo

will invoke the JVM to execute the application.

With Eclipse, you can execute your own source code from within the IDE.

If you don't have the source code, you might be able to decompile it.
Just do a Google search on "Java decompilers" to find out more...

Hope this helps...

Mike.

--- ACGNJ Java Users Group (http://www.javasig.org/)
 

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,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top