简体   繁体   English

如何在Eclipse中使用Java .class文件?

[英]How do I use a Java .class file in Eclipse?

I have a homework assignment that requires us to use functions in a provided .class file. 我有一项家庭作业,要求我们使用提供的.class文件中的函数。 I'm trying to add it in Eclipse, but I'm not having any luck. 我试图在Eclipse中添加它,但是我没有任何运气。

The .class file is not part of a package, and I am not submitting it with my .java files. .class文件不是软件包的一部分,因此我不与.java文件一起提交。 This means I cannot change the directory of the .class file, it needs to be in the same directory with all my .java files. 这意味着我无法更改.class文件的目录,它必须与所有.java文件位于同一目录中。 I don't think I can add an external class folder with these requirements. 我认为我无法根据这些要求添加外部类文件夹。 Adding the file to a .jar is also out of the question. 将文件添加到.jar也是不可能的。

How can I get my java code to recognize the methods in the .class file? 如何获取我的Java代码以识别.class文件中的方法?

You need to add the class folder where your .class file is located. 您需要添加.class文件所在的类文件夹。 To do that go to the Project Properties -> Java Build Path -> Add Class Folder 为此,请转到项目属性-> Java构建路径->添加类文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM