I'm about to finish my master thesis. The program, i developed, is a maven project with javaFx declared as dependencies
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>16-ea+4</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>8.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>16-ea+4</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>16-ea+4</version>
</dependency>
When I'm creating the jar using Maven-install the program runs on Oracle-JDK. But on openJDK it throws a java.lang.ClassNotFoundException.
My understanding is, that javaFX is not included in both JDKs anymore. Thats why I'm unsing maven and build the jar with all dependencies. That way it should find javaFx and start the program regardless the used JDK.
Assuming my assumption is correct that the error has something to do with javaFX.
To compile the Program I'm using JavaSE 13. It runs perfectly using Oracle JDK 15. But it throws a java.lang.ClassNotFoundException using openJDK 14 or 15.
---EDIT---
I'm not totaly sure if this error is regarded to JavaFX.
I'm starting the jar on the console with
java -jar "C:...\test.jar"
This works on the OracleJDK but not on the openJDK. Then the Console prinst:
Error: Could not find or load main class C:\...\test
Caused by: java.lang.ClassNotFoundException: C:\...\test
I know how to print the stacktrace, using the IDE. But is it possible to print the stacktrace using the console in this case?
If so I will do it an edit this question to provide more info.
I would be so grateful for your help. I panic ^^
You are only providing us with some fragments of your setup. So it is difficult to give any specific advice. From what I see I'd say that your program cannot work on any Java which does not contain JavaFX because you do not provide the required arguments in your launch command. Have a look here for proven ways to launch JavaFX correctly: https://openjfx.io/openjfx-docs/
Do you have a MANIFEST.MF file? IT should point towards the class that has your public static void main(String[] args) method <-- Your main method.
Example:
MANIFEST.MF
Manifest-Version: 1.0
Main-Class: classes.TestClass
Helpful stackoverflow: Could not find or load main class with a Jar File
https://taylorial.com/cs1021/Jar.htm#jarwithjavafxpackagesincluded
my Prof just responded and says that it was just a typo in his commandline.
It works perfectly fine.
I will delete this question in view hours, cause it is not really a problem.
Thank you very much.
Maybe a newbie question...
I've been working on a LWJGL project, where I use Maven to manage dependencies. In it, I want to use some parts of the libgdx library. So I figured I will first run at least a helloworld working with it before I add it to my main project.
So in my pom.xml I have this:
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-backend-lwjgl -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>1.9.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-platform -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>1.9.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<version>1.9.11</version>
</dependency>
The other contents of the file are the same as in a working project and are 100% working.
I tried creating a separate libgdx project before that and... it didn't work. But, I saw that the code that was supposed to run the program was:
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new SomeApplicationListenerFile(), config);
}
So I used that in my maven project.
When I do "run as a Java Application", the error is the following:
Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/backends/lwjgl/LwjglApplicationConfiguration
at org.boby.RayTracing.main.Main.main(Main.java:179)
And if I do a Maven Build, it tells me that "package com.badlogic.gdx.backends.lwjgl does not exist"
I looked for that package in the jars Maven downloaded in the "Maven dependencies" folder and I found it in gdx-backend-lwjgl-1.9.11.jar - right where it should be.
The package is apparently there, but Java cannot find it. How can I fix that?
Some additional information:
Windows 10, eclipse oxygen, Maven 3.6.0, JRE 1.8.0_191, JDK 8
Thank you in advance! I've been banging my head on this for hours.
Edit: I made some progress. Looks like the "test" was messing things up so I removed those statements. Now I get the following Error:
Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx64.dll' for target: Windows 10, 64-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125)
at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)
at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(LwjglNativesLoader.java:47)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:83)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:71)
at org.boby.RayTracing.main.Main.main(Main.java:178)
It looks like I need to include gdx-natives.jar in my dependencies, but I can't find a maven repository for it.
I downloaded gdx-natives.jar (saw it in a forum thread). In there, was a file named "gdx-64.dll". As I need "gdx64.dll", I just renamed the dll and now it runs.
You can let Maven do the work if you define the gdx-platform dep like this:
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>1.9.11</version>
<classifier>natives-desktop</classifier>
</dependency>
This will load the natives jar including the gdx64.dll so you don't have to add any external jar to your project in the build path.
A side note is: if you use the standard Maven repo directory structure and you load assets with the Gdx.files.internal("fileName") statement you need to define a folder in the main/repository with the same name as the package you have your code in. (i.e. main/java/myPackage relates to /main/repository/myPackage). I struggled a bit with this because I don't normaly have to define a package folder int the repository dir.
I am very new to using cucumber (started today).
It seems simple enough but I am having issues running a basic feature.
Feature: Proof of concept that my framework works
Scenario: My first test
Given this is my first step
When this is my second step
Then this is my final step
I know there is no code for it to test, but I wanted it to return the fact that the scenarios are undefined.
I did some research and realised I had a .jar file which was unnecessary, I have since removed that.
I still have the following issue:
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding
Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding
There some more info from the exception.
Is there any other info I should provide?
Any help would be appreciated
I had this same problem when running through the First Steps chapter in The Cucumber for Java book.
It says to download the latest version of the Gherkin jar (among others) from
http://repo1.maven.org/maven2/info/cukes/gherkin/
Below is the listing, where, on the webpage, each one is a directory-link containing the jar. My mistake was thinking that the bottom-most version is the most recent version. It's not. For all of the other jars, the bottom-most is indeed the most recent version.
When using the bottom-most Gherkin jar, I get the CNFX exactly as you describe:
Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding
Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding
The version-number listing, as on the above webpage:
2.10.0/
2.11.0/
2.11.1/
2.11.2/
2.11.4/
2.11.5/
2.11.6/
2.11.7/
2.11.8/
2.12.0/
2.12.1/
2.12.2/
2.4.16/
2.4.17/
2.4.18/
2.4.19/
2.4.20/
2.4.21/
2.5.0/
2.5.1/
2.5.2/
2.5.3/
2.5.4/
2.6.0/
2.6.1/
2.6.2/
2.6.3/
2.6.4/
2.6.5/
2.6.6/
2.6.7/
2.6.8/
2.6.9/
2.7.0/
2.7.1/
2.7.2/
2.7.3/
2.7.4/
2.7.5/
2.7.6/
2.7.7/
2.8.0/
2.9.0/
2.9.1/
2.9.2/
2.9.3/
Make sure you have the cucumber java libraries in your CLASSPATH.
Its an setup issue as it is not finding the required cucumber classes to interpret gherkin statements.
Provide more info on the files you included in the setup.
Rather than downloading individual jars, use a package manager to download the dependencies.
Using Maven, add the following dependencies to the pom.xml:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
NB. This is currently the latest version.
Make sure to use the same version for all Cucumber dependencies.
I am trying to use the JZY3D libraries in my Java project.
Starting with the basic, I set up the following main():
public static void main(final String[] args) {
new GLCapabilities(GLProfile.getDefault());
}
The jogl-all.jar, gluegen-rt.jar and gluegen.jar files are in the build path. I get the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: javax.media.opengl.GLDrawableFactory.initSingleton()V
at javax.media.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1444)
at javax.media.opengl.GLProfile.access$100(GLProfile.java:76)
at javax.media.opengl.GLProfile$1.run(GLProfile.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:140)
at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:199)
at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1914)
at javax.media.opengl.GLProfile.get(GLProfile.java:815)
at javax.media.opengl.GLProfile.getDefault(GLProfile.java:602)
at javax.media.opengl.GLProfile.getDefault(GLProfile.java:613)
at eu.crisis_economics.abm.model.SpecsCompetitionStrategyCFO.main(SpecsCompetitionStrategyCFO.java:312)
It seems like there is a problem with the 3d libraries, but I cannot figure out what.
The jogl-all.jar, gluegen-rt.jar and gluegen.jar files are in the build path. I get the following exception:
Remove gluegen.jar from the build path.
Make sure these two jars are added to the classpath at runtime as well!
You only need jogl-all.jar and gluegen-rt.jar (rt == runtime) at compile time and runtime.
Also you need to have a copy of the matching native jars gluegen-rt-natives-os.and.arch.jar and jogl-all-natives-os.and.arch.jar for the platform you use next to the gluegen-rt.jar and jogl-all.jar
http://jogamp.org/jogl/doc/deployment/JOGL-DEPLOYMENT.html#NativeJARFiles
Have you tried the Maven dependency instead of add those jars by hand?
I made a clean maven project, add a new user library with the following files:
org.jzy3d-0.9.jar
dependencies/misc/opencsv-2.1.jar
dependencies/misc/org.convexhull.jar
dependencies/misc/swt.jar
dependencies/misc/swt-debug.jar
After that, I add the following maven dependencies:
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all-main</artifactId>
<version>2.0.2</version>
</dependency>
Build & Run with no exceptions.
A much cleaner solution is:
Clone Jzy3D repository (https://github.com/jzy3d/jzy3d-api)
install jzy3d-master
add the jzy3d-api dependency for your project
i am executing simple Dependency Injection program of spring & getting this exception.
I have already included common-logging1.1.1.jar and spring.jar file. Could you please help to out?
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)
at com.client.StoryReader.main(StoryReader.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 6 more
If you're using maven for managing dependencies, add the following lines in your pom.xml:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
I have also faced the same issues, to fix, download the jar files from the below url
http://commons.apache.org/logging/download_logging.cgi
and copy to your lib folder, will resolve your issue.
You just download commons-logging-1.1.2.jar and then copy this file in to libs
finally, it works.
commons-logging-1.1.1.jar or jcl-over-slf4j-1.7.6.jar al
If you are using maven, use the below code.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
I had the same problem, and solved it by just adding the commons-logging.jar to the class path.
Setting the scope to compile did it for me
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
Adding commons-logging.jar or commons-logging-1.1.jar will solve this...
I have already included common-logging1.1.1.jar and ...
Are you sure you spelled the name of the JAR file exactly right? I think it should probably be commons-logging-1.1.1.jar (note the extra - in the name). Also check if the directory name is correct.
NoClassDefFoundError always means that a class cannot be found, so most likely your class path is not correct.
Try doing a complete clean of the target/deployment directory for the app to get rid of any stale library jars. Make a fresh build and check that commons-logging.jar is actually being placed in the correct lib folder. It might not be included when you are building the library for the application.
Issue solved by adding commons-logging.jar
Imp files are ,
antlr-runtime-3.0.1
org.springframework.aop-3.1.0.M2
org.springframework.asm-3.1.0.M2
org.springframework.aspects-3.1.0.M2
org.springframework.beans-3.1.0.M2
org.springframework.context.support-3.1.0.M2
org.springframework.context-3.1.0.M2
org.springframework.core-3.1.0.M2
org.springframework.expression-3.1.0.M2
commons-logging-1.1.1
Two options (at least):
Add the commons-logging jar to your file by copying it into a local folder.
Note: linking the jar can lead to problems with the server and maybe the reason why it's added to the build path but not solving the server startup problem.
So don't point the jar to an external folder.
OR...
If you really don't want to add it locally because you're sharing the jar between projects, then...
If you're using a tc server instance, then you need to add the jar as an external jar to the server instance run configurations.
go to run as, run configurations..., {your tc server instance}, and then the Class Path tab.
Then add the commons-logging jar.
I got the same trouble than you.
Finally I checked the version of apache possessing the class.
I found that the version 1.0.4 has the class.
Try to use the version 1.0.4 instead of 1.1.X or 1.2.X
My dependencies :
<dependencies>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-core</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.jolokia</groupId>
<artifactId>jolokia-client-java</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
My Java Code
J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia");
J4pReadRequest req = new J4pReadRequest("java.lang:type=Memory","HeapMemoryUsage");
req.setPath("used");
J4pReadResponse resp = j4pClient.execute(req);
System.out.println(resp.getValue());
My Result :
130489168
Double check also that your maven dependencies are well imported.
http://commons.apache.org/logging/download_logging.cgi
use this url to download jar files and include them in your class path, issue will be solved
The topic is very outdated. But it still can be met ourdays.
commons-logging, or also known as jcl is a deprecated library. The last version was exposed in 2014
You should avoid adding dependency on it directly in your projects. I assume the most of answers and the accepted one are not actual anylonger.
A preferrable way to use in your projects new alternatives, like slf4j or log4j2, which play the same role, as jcl. The reasons and motivation is another big topic, not for the scope of this issue.
If your application uses log4j2, and you meet the error, add dependency:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.y.z</version>
</dependency>
If you prefer slf4j, (already offered in previous comments/replies ) use:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
If you use Spring, most probably you have in the dependency tree:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
</dependency>
and it solves the issue as well.
In the examples I skipped certain versions by purpose, they get deprecated very quickly, see Offitial Maven repository.
In some cases you should not use version attribute at all, preferring using dependencies from BOM files. Spring is an example.
Just check whether the commons-logging.jar has been added to your libs and the classpath.. I had the same issue and that was because of this.
dhammikas-
I generally assign the classpath to a variable and then verify it. I've written a small ruby script which I include in a my startup scripts which validates the classpath before launching java. Validating the classpath before the JVM starts has saved me lots of time troubleshooting these types of problems.
Hey I was following the tutorial on tutorialpoint.com. Add after you complete Step 2 - Install Apache Common Logging API: You must import external jar libraries to the project from the files downloaded at this step. For me the file name was "commons-logging-1.1.1".
If you're running this on Android then note that apparently java.beans package is not complete on Android. To attempt to fix it on Android try the following:
Download android-java-air-bridge.jar (currently the download button is on the bottom of the page or direct link here)
Copy the downloaded jar to your [APPROOT]/app/libs directory (or link the jar in any other way)
Change the import *** statements to that of air-bridge. Eg import javadz.beanutils.BeanUtils instead of import org.apache.commons.beanutils.BeanUtils;
Clean and rebuild the project
source 1, source 2
I apologise as I realise this is not exactly answering the question, though this SO page comes up a lot when searching for android-generated NoClassDefFoundError: Failed resolution of: beanUtils errors.
I was getting the same error while the jar was present. No solution worked. What worked was deleting the jar from the file system (from .m2 directory) and then cleaning the maven project.
I have the same problem in eclipse IDE, my solution was:
Right click in My project > Properties
Click in Maven and write: jar in the Active Maven Project
Finally, Apply and Close
In my case I was testing a Tomcat app in eclipse and got this error. I solved it by checking the .classpath file and corrected this entry:
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
The attribute org.eclipse.jst.component.dependency had been missing.
Check whether the jars are imported properly. I imported them using build path. But it didn't recognise the jar in WAR/lib folder. Later, I copied the same jar to war/lib folder. It works fine now. You can refresh / clean your project.
Hello friends if your getting any not class found exception in hibernate code it is the problem of jar files.here mainly two problems
1.I mean to say your working old version of hibernate may be 3.2 bellow.So if u try above 3.6 it will works fine
2.first checkes database connection.if it database working properly their was a mistake in ur program or jar file.
please check these two prioblems if it also not working you tried to IDE . I am using netbeanside 6.9 version.here hibernate working fine.you dont get any error from class not founnd exception..
I hope this one helps more
try adding this dependency
org.apache.commons
commons-exec
1.3
If all else fails, as it had for me, try putting the commons-logging-x.y.z.jar in your Tomcat lib directory. It solved the problem! BTW, I am using Tomcat 6.
Solution is to Add common-logging.x.x jar file