Before I asked about how to execute a class here
In summary the sentence that has worked for me has been:
java -cp . com.index.Clase
The problem is that when executing that sentence, it throws an exception saying that it does not find one of the several libraries that I use:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.api.client.Client
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)
... 7 more
Looking through stackOverflow in I found this example:
java -cp c:\location_of_jar\myjar.jar com.mypackage.myClass
In my case following the structure:
C:
\Programa
| \com
| \index
| Clase.class
jersey-client-1.9.1.jar
Execute:
C:\Programa>java -cp jersey-client-1.9.1.jar . com.index.Clase
He throws me again the same exception as at the beginning.
By the way I'm not sure what the .
means but without it it does not work for me.