@Override
            public void onAction(String name, boolean keyPressed, float tpf) {
                Sphere bullet = new Sphere(32, 32, 0.4f, true, false);
                bullet.setTextureMode(TextureMode.Projected);
                Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
                TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
                key2.setGenerateMips(true);
                Texture tex2 = app.getAssetManager().loadTexture(key2);
                mat2.setTexture("ColorMap", tex2);
                if (name.equals("shoot") && !keyPressed) {
                    Geometry bulletGeometry = new Geometry("bullet", bullet);
                    bulletGeometry.setMaterial(mat2);
                    bulletGeometry.setShadowMode(ShadowMode.CastAndReceive);
                    bulletGeometry.setLocalTranslation(app.getCamera().getLocation());
                    RigidBodyControl bulletControl = new RigidBodyControl(10);
                    bulletGeometry.addControl(bulletControl);
                    bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25));
                    bulletGeometry.addControl(bulletControl);
                    rootNode.attachChild(bulletGeometry);
                    space.add(bulletControl);
                }
            }
creates the necessary input listener and action to shoot balls from the camera

@param app the application that's running
@param rootNode where ball geometries should be added
@param space where collision objects should be added
jme3-examples/src/main/java/jme3test/bullet/PhysicsTestHelper.java