简体   繁体   中英

Using Java.applet.Applet in Eclipse

I am little .NET oriented, and new to Java stuff. Using Eclipse IDE, whenever i extend my class by Applet as:

class xyz extends Applet{ . . . };

this gives error. and no suitable oauto-fix. i tried importing manually as

import java.applet.Applet;

But this gives error too. I tried to look up for the problem over internet, but only find the way to create applet, not the solution. Kindly guide me. Do I have to import some files in my Eclipse IDE?

(i forgot to mention, I am using it in my Android Application Project )

As Mr. Thompson said, applets don't work in android. The tutorial you posted may does some Android stuff later - however not in that specific tutorial you linked (" But wait until we start developing on Android " [...at some day in the future and in some other tutorial]). And as you may see the first screenshot he selects

"Package Explorer >> New >> Java Project " and not the below Android Application Project.

So did you really (exactly) followed that tutorial step by step? If so, everything should be working. If not you made a mistake or your eclipse is misconfigured.

In your project in Eclipse, check if you have JRE System Library, like this 1
(source: ibm.com )

If not, Go to Window - Preferences - Java - Installed JREs page to specify the path of your JRE or JDK.

whenever you import any class using import statement, it will import from JRE which is linked to Eclipse IDE.

If your IDE not linked to JRE then you will get this type of errors.

to remove these errors, first set some settings in Eclipse.

go to window >> Preferences - you can see one screen now.

here you can go to java >> Installed JREs

if there are no JRE then you can add JRE from your local C: drive.

generally you can find your JRE on the location below(if you have windows machine): C:\\Program Files\\Java\\jre7 (if you have 32 bit OS) OR C:\\Program Files (x86)\\Java\\jre7 (if you have 64 bit OS)

you can also set the compiler compliance level same as your JRE version or below to JRE version but not upper version .(for this you can go to java >> compiler)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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