Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use a .class file with .java files

Tags:

java

import

class

I'm quite green to java (I program in C/C++) and I still haven't figured out how this all works together.

I'm not trying to ask for anyone to do my homework, I'm just confused about some basic java stuff. I have an assignment which wants me to create a maze. The assignment comes with some files which have been pre-implemented and theoretically works. The folder gives me some .java files and some .class files. I opened the .java files and most of them are interfaces with no real code, so I'm assuming the meat of it are in these .class files. My question is, how do I interface with these .class files? do I need to do something like import myClass; if I have a file called myClass.class?

I've tried importing the file directory which these files are contained in (through Eclipse), but it seems the .class files don't show up. I'm guessing it's being processed in the background?

Here's a link to the assignment http://www.ics.uci.edu/~goodrich/teach/ics23/LabManual/Dark/

Here's the zip file with all the .java and .class files http://www.ics.uci.edu/~goodrich/teach/ics23/LabManual/Dark/Dark.zip

Thanks in advance!

like image 386
foboi1122 Avatar asked Jun 28 '11 17:06

foboi1122


People also ask

How do I get a .java file from a .class file?

You can use a decompiler to do so. One of the most major ones is JD-GUI. JD-Core is a library that reconstructs Java source code from one or more “. class” files.

What is use of .class file in Java?

Java File class represents the files and directory pathnames in an abstract manner. This class is used for creation of files and directories, file searching, file deletion, etc. The File object represents the actual file/directory on the disk. Following is the list of constructors to create a File object. Sr.No.

How does a .class file differ from a .java file?

A . java file contains your Java source code while a . class file contains the Java bytecode produced by the Java compiler.

Can Java read .class files?

The Java Runtime Environment (JRE) can execute CLASS files, but it cannot compile them since it does not include the javac binary.


1 Answers

To add .class files to your project in Eclipse: right-click your project, select properties --> Java Build Path --> Libraries and click on Add Class Folder button. Select the folder with the classes.

like image 151
Tarlog Avatar answered Sep 28 '22 18:09

Tarlog