开发者

Access external class files in java using eclipse

I have a class file to handle the GUI which is SampleGUI.class. I want to use that into my java p开发者_运维百科roject. I have created a folder named ClassFiles in root directory. I put the SampleGUI.class inside that folder. I went to project properties ->Libraries->Add Class Folder. Then i tried to call that class inside my new class created inside the project like

new SampleGUI ( length, width) ;. But it gives me the error "SampleGUI cannot be resolved to a type". Do i need to import anything? How do i procees with this situation?


I have create a Jar file using the command

jar cf jar-file input-file(s)

And I imported those jar files into my project and it all worked fine.


If SampleGUI is in a different package, you'll need to import it.

e.g.

import ClassFiles.SampleGUI;

where ClassFiles is the package name.

If SampleGUI is your own, and you have the .java source file, you can add SampleGUI to the ClassFiles package, if it isn't already, by adding the following line to the top of SampleGUI:

package ClassFiles;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜