java - Why do I get the "Selection does not contain a main type" when my class has a main? -
i above error msg class have main method:
package adventure; import com.jme3.system.appsettings; import java.applet.applet; import java.applet.audioclip; import java.awt.image; import java.io.file; import java.net.malformedurlexception; import java.net.url; import com.jme3.renderer.queue.renderqueue.shadowmode; import com.jme3.animation.animchannel; import com.jme3.animation.animcontrol; import com.jme3.animation.animeventlistener; import com.jme3.animation.loopmode; import com.jme3.app.simpleapplication; import com.jme3.asset.blenderkey; import com.jme3.asset.plugins.httpziplocator; import com.jme3.asset.plugins.ziplocator; import com.jme3.bullet.bulletappstate; import com.jme3.bullet.physicsspace; import com.jme3.bullet.collision.shapes.capsulecollisionshape; import com.jme3.bullet.control.charactercontrol; import com.jme3.bullet.control.rigidbodycontrol; import com.jme3.input.chasecamera; import com.jme3.input.keyinput; import com.jme3.input.controls.actionlistener; import com.jme3.input.controls.keytrigger; import com.jme3.light.ambientlight; import com.jme3.light.directionallight; import com.jme3.material.materiallist; import com.jme3.math.colorrgba; import com.jme3.math.vector3f; import com.jme3.post.filterpostprocessor; import com.jme3.post.filters.bloomfilter; import com.jme3.scene.node; import com.jme3.scene.spatial; import com.jme3.scene.plugins.ogre.ogremeshkey; import com.jme3.input.controls.mousebuttontrigger; import com.jme3.input.mouseinput; public class q3world extends simpleapplication implements actionlistener, animeventlistener, playable { private node gamelevel; //private physicscharacter player; private static boolean usehttp = false; //private static world world; //private static person person; //private static player dplayer; private bulletappstate bulletappstate; private animchannel channel; private animcontrol control; // character charactercontrol character; charactercontrol goblincharacter; node model; // temp vectors vector3f walkdirection = new vector3f(); spatial goblin; rigidbodycontrol terrainphysicsnode; // animation animchannel animationchannel; animchannel shootingchannel; animcontrol animationcontrol; float airtime = 0; // camera boolean left = false, right = false, = false, down = false, attack=false; chasecamera chasecam; filterpostprocessor fpp; private spatial scenemodel; private rigidbodycontrol landscape; public static void main(string[] args) { file file = new file("quake3level.zip"); if (!file.exists()) { usehttp = true; } q3world app = new q3world(); appsettings settings = new appsettings(true); settings.settitle("dungeon world"); settings.setsettingsdialogimage("interface/splash.png"); app.setsettings(settings); app.start(); } @override public void simpleinitapp() { bulletappstate = new bulletappstate(); bulletappstate.setthreadingtype(bulletappstate.threadingtype.parallel); statemanager.attach(bulletappstate); setupkeys(); directionallight dl = new directionallight(); dl.setcolor(colorrgba.white.clone().multlocal(2)); dl.setdirection(new vector3f(-1, -1, -1).normalize()); rootnode.addlight(dl); ambientlight = new ambientlight(); am.setcolor(colorrgba.white.mult(2)); rootnode.addlight(am); if (usehttp) { assetmanager .registerlocator( "http://jmonkeyengine.googlecode.com/files/quake3level.zip", httpziplocator.class); } else { assetmanager.registerlocator("quake3level.zip", ziplocator.class); } // create geometry , attach materiallist matlist = (materiallist) assetmanager .loadasset("scene.material"); ogremeshkey key = new ogremeshkey("main.meshxml", matlist); gamelevel = (node) assetmanager.loadasset(key); gamelevel.setlocalscale(0.1f); gamelevel.addcontrol(new rigidbodycontrol(0)); getphysicsspace().addall(gamelevel); rootnode.attachchild(gamelevel); getphysicsspace().addall(gamelevel); createcharacters(); setupchasecamera(); setupanimationcontroller(); setupfilter(); } private void setupfilter() { filterpostprocessor fpp = new filterpostprocessor(assetmanager); bloomfilter bloom = new bloomfilter(bloomfilter.glowmode.objects); fpp.addfilter(bloom); viewport.addprocessor(fpp); } private physicsspace getphysicsspace() { return bulletappstate.getphysicsspace(); } private void setupkeys() { inputmanager.addmapping("wireframe", new keytrigger(keyinput.key_t)); inputmanager.addlistener(this, "wireframe"); inputmanager.addmapping("charleft", new keytrigger(keyinput.key_a)); inputmanager.addmapping("charright", new keytrigger(keyinput.key_d)); inputmanager.addmapping("charup", new keytrigger(keyinput.key_w)); inputmanager.addmapping("chardown", new keytrigger(keyinput.key_s)); inputmanager.addmapping("charspace", new keytrigger(keyinput.key_space)); inputmanager .addmapping("charshoot", new mousebuttontrigger(mouseinput.button_left)); inputmanager.addlistener(this, "charleft"); inputmanager.addlistener(this, "charright"); inputmanager.addlistener(this, "charup"); inputmanager.addlistener(this, "chardown"); inputmanager.addlistener(this, "charspace"); inputmanager.addlistener(this, "charshoot"); } private void createcharacters() { capsulecollisionshape capsule = new capsulecollisionshape(0.05f, 0.05f); character = new charactercontrol(capsule, 2); character.setjumpspeed(20f); model = (node) assetmanager.loadmodel("models/ninja/ninja.mesh.xml"); model.scale(0.05f, 0.05f, 0.05f); model.addcontrol(character); character.setphysicslocation(new vector3f(55, 15, -60)); model.setshadowmode(shadowmode.castandreceive); character.setviewdirection(new vector3f(1, 0, 0)); rootnode.attachchild(model); getphysicsspace().add(character); blenderkey blenderkey = new blenderkey("models/oto/oto.mesh.xml"); spatial man = (spatial) assetmanager.loadmodel(blenderkey); man.setlocaltranslation(new vector3f(67, 15, -60)); man.setshadowmode(shadowmode.castandreceive); rootnode.attachchild(man); goblin = assetmanager.loadmodel("objects/goblin.j3o"); goblin.scale(4f, 4f, 4f); //goblin.setlocaltranslation(60, 3.5f, -60); goblincharacter = new charactercontrol(capsule, 2); goblin.addcontrol(goblincharacter); goblincharacter.setphysicslocation(new vector3f(60, 3.5f, -60)); //goblincharacter.setviewdirection(new vector3f(1, 0, 0)); //character.setwalkdirection(new vector3f(1, 0, 0)); control = goblin.getcontrol(animcontrol.class); control.addlistener(this); channel = control.createchannel(); (string anim : control.getanimationnames()) system.out.println("goblin can:"+anim); channel.setanim("walk"); rootnode.attachchild(goblin); getphysicsspace().add(goblincharacter); spatial monster = assetmanager.loadmodel("objects/creatures/monster/monster.packed.j3o"); spatial monster2 = assetmanager.loadmodel("models/jaime/jaime.j3o"); monster2.scale(5f, 5f, 5f); monster.scale(2f, 2f, 2f); monster.setlocaltranslation(new vector3f(53, 3, -55)); monster2.setlocaltranslation(new vector3f(50, 3, -55)); rootnode.attachchild(monster2); rootnode.attachchild(monster); } private void setupchasecamera() { flycam.setenabled(false); chasecam = new chasecamera(cam, model, inputmanager); chasecam.setdefaultdistance(27); } private void setupanimationcontroller() { animationcontrol = model.getcontrol(animcontrol.class); animationcontrol.addlistener(this); animationchannel = animationcontrol.createchannel(); //shootingchannel = animationcontrol.createchannel(); } @override public void simpleupdate(float tpf) { goblincharacter.setwalkdirection(goblin.getlocalrotation().mult(vector3f.unit_z).multlocal(0.4f)); vector3f camdir = cam.getdirection().clone().multlocal(0.1f); vector3f camleft = cam.getleft().clone().multlocal(0.1f); camdir.y = 0; camleft.y = 0; walkdirection.set(0, 0, 0); if (left) { walkdirection.addlocal(camleft); } if (right) { walkdirection.addlocal(camleft.negate()); } if (up) { walkdirection.addlocal(camdir); } if (down) { walkdirection.addlocal(camdir.negate()); } //if (attack) { //animationchannel.setanim("attack1"); //animationchannel.setloopmode(loopmode.dontloop); //} if (!character.onground()) { airtime = airtime + tpf; } else { airtime = 0; } if (walkdirection.length() == 0) { if (!"idle1".equals(animationchannel.getanimationname())) { animationchannel.setanim("idle1", 1f); } } else { character.setviewdirection(walkdirection.negate()); if (airtime > .3f) { if (!"stand".equals(animationchannel.getanimationname())) { animationchannel.setanim("idle1"); } } else if (!"walk".equals(animationchannel.getanimationname())) { animationchannel.setanim("walk", 1f); } } character.setwalkdirection(walkdirection); } /*ninja can: walk ninja can: kick ninja can: jumpnoheight ninja can: jump ninja can: spin ninja can: attack1 ninja can: idle1 ninja can: attack3 ninja can: idle2 ninja can: attack2 ninja can: idle3 ninja can: stealth ninja can: death2 ninja can: death1 ninja can: highjump ninja can: sidekick ninja can: backflip ninja can: block ninja can: climb ninja can: crouch*/ public void onaction(string binding, boolean value, float tpf) { if (binding.equals("charleft")) { if (value) { left = true; } else { left = false; } } else if (binding.equals("charright")) { if (value) { right = true; } else { right = false; } } else if (binding.equals("charup")) { if (value) { = true; } else { = false; } } else if (binding.equals("chardown")) { if (value) { down = true; } else { down = false; } } else if (binding.equals("charspace")) { character.jump(); } else if (binding.equals("charshoot") && value) { //bulletcontrol(); vector3f origin = cam.getworldcoordinates(inputmanager.getcursorposition(), 0.0f); vector3f direction = cam.getworldcoordinates(inputmanager.getcursorposition(), 0.0f); //direction.subtractlocal(origin).normalizelocal(); //character.setwalkdirection(location); system.out.println("origin"+origin); system.out.println("direction"+direction); //character.setviewdirection(direction); animationchannel.setanim("attack3"); animationchannel.setloopmode(loopmode.dontloop); } } public void onanimcycledone(animcontrol control, animchannel channel, string animname) { if (channel == shootingchannel) { channel.setanim("idle1"); } } public void onanimchange(animcontrol control, animchannel channel, string animname) { } // load image net, making sure has been // loaded when method returns public image loadpicture(string imagename) { return null; } // load , play sound /usr/local/hacks/sounds/ public void playsound(string name) { url u = null; try { u = new url("file:" + "/usr/local/hacks/sounds/" + name + ".au"); } catch (malformedurlexception e) { } audioclip = applet.newaudioclip(u); a.play(); } }
since happens on windows 7 , not on ubuntu code written, suppose it's setting or build path in eclipse juno windows 7 setting must set?
try cleaning , rebuilding project. make sure .java files in .src folder.
also check if source folder exists in project properties -> java build path -> source.
Comments
Post a Comment