java如何导入文件怎么打开,如何在.java文件中导入.class文件?

在Eclipse中,你需要将Scheme转换的Java类文件添加到项目的类路径。右击项目,选择属性,然后是Java构建路径,通过添加外部类文件夹或内部类文件夹将包含.class文件的目录引入。确保类文件所在的包结构与添加的包相匹配。在Java文件中使用`import`语句导入所需的类,并尝试调用其函数。如果你无法访问这些函数,检查类路径设置是否正确。
摘要由CSDN通过智能技术生成

What i need to do is as follows:

I have a bigloo scheme program (*.scm), then using the bigloo frameworks jvm a class file is generated.

I want to use this .class file from a .java file. That is, i need to import this(.class) file as i want to use some functions defined in the scheme file which is now a .class file.

How do i do it in Eclipse? i have created two packages one for java and one for the .class file. Then i import the package containing the .class file. But i am not able to use the function in the .class file in the .java file. Are there any settings to be done?

Please let me know how this can be done.

解决方案

You can add a folder containing compiled classes to your project by right clicking the project, then select Properties > Java build path, then "Add External Class Folder"

Or choose "Add Class Folder" if you have copied the class files into a sub directory of your project.

This will add the class files to the projects classpath and you can then import the class into your java file using an import statement:

import my.package.MyClass;

Note: The package structure should be maintained under the folder that you add as a class folder. So if you add folder "myclasses" as a class folder, the directory structure should be as follows for the example above:

myclasses/my/package/MyClass.class

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值