Search code examples
javalibgdxprogram-entry-point

error while running main function without libgdx


I have been using libGdx for a while now. I have created a new project without using libGdx and created some class trying to practice some code if it works as I intended. However, I'm getting error that main class is not found in the libgdx package. How Do I switch between libgdx and just native IDE.

So for example...

package com.example.example;


public class Example
{
     public static void main (String[] args)
    {
        System.out.println("hey");


    }
}

when i try to run this code I get error

Exception in thread "main" java.lang.NoClassDefFoundError:         com/badlogic/gdx/jnigen/BuildTarget$TargetOs
    at com.badlogic.gdx.physics.box2d.utils.Box2DBuild.main(Box2DBuild.java:13)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.jnigen.BuildTarget$TargetOs
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

How do I fix this? Thanks in advance!


Solution

  • I ran into this error today and Lestat was correct.

    In your IDE (in my case Eclipse): go to Run> Run As> Java application.