开发者

Java import error in eclipse

开发者 https://www.devze.com 2022-12-18 16:04 出处:网络
I have a code written in java. when i load it in eclipse it shows an error in the java code import line \" The import com.sun.开发者_C百科java.browser.plugin2 cannot be resolved\"

I have a code written in java. when i load it in eclipse it shows an error in the java code import line " The import com.sun.开发者_C百科java.browser.plugin2 cannot be resolved"

import com.sun.java.browser.plugin2.*;

How can i fix this error..??


It's possible that it's to do with the version of Java you're building your project with, since the new applet class files were only introduced in Java 1.6 / 6.0. So, right click on your project on the left, go to Properties, Java Build Path, Libraries tab, and scroll down the list until you see JRE System Library. Note the version. If it reads less than 6.0 / 1.6, you're using an old version.

Click on JRE System Library, click Remove (make sure you have at least Java 1.6 installed!) then click Add Library. Select JRE System Library and select your Java version. If this isn't listed, go to Window > Preferences, Java > Installed JREs, click Add, and locate your JRE. Then repeat the same process and it should work.

(Edit: ignore what I said, the com.sun.* classes are hidden from the user. I don't think you can use it)


As far as I know, packages com.sun.* are implementation details of certain jvm and must not be used by application developers. They can be slightly different even between minor versions of jvm. Difference between major versions or jvms of different vendors can be sufficient. So IBM's and Sun's jvms have different structure of those packages. Only packages java.* and javax.* and org.* should be used. To fix this error correctly you must not use this package. To hack it around, you can try configure eclipse to use appropriate jvm though I don't know how to do it.

Update: There's a FAQ entry about those packages. Thanks to R. Bemrose.


Did you type this in? Then the build path in incorrect. If not no sure what is going on.


Are you sure you are using the right JRE for your project? Like Java6?
See also JRE settings, and then make sure your project uses a Java6 JRE.


You have to add the plugin to the MANIFEST.MF dependency entry

  • Open MANIFEST.MF
  • Got to tab Dependencies
  • Add the plugin your referenced class is placed

You also have to be sure, that the package, the called class is lying, is added in the "Runtime" tab of the MANIFEST file.

EDIT:

The MANIFEST file you can find in the /META-INF directory

0

精彩评论

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