Issue with running jar file with imported libraries?
I am relatively new to Java, and I have made a script which uses the LWJGL 3. The program runs perfectly fine within the Eclipse IDE but when I attempt to export it as a runnable Jar file (I checked package required libraries field) and then attempt to run it through windows command line I get the error message as follows:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
at renderEngine.TestEngine.main(TestEngine.java:18)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more
I am assuming this is an issue caused by a lack of access to the libraries I imported, but after searching the web for a while I could not find a single proper guided answer to solving the question. Most of the time it was someone asking the question and then just stating they solved it themselves or someone else explaining the issue but not actually assisting with it. I am hoping someone can assist me with a guided explanation of how to fix this issue, and also if it could be explained as to avoid future issues.
If any more information is needed to assist with the issue I will be happy to provide it.
UPDATE:
It seems that the issue is with GLFW and not the library as a whole. As re-reading the error, the only thing that cannot be found or loaded is GLFW when I am also using other imports from the same library such as OpenGL. Also, the line it specifies is the line in which I call a function from GLFW and not when I import the package, don't know if that is because errors don't get called when imports are unsuccessful or if there is another issue possibly within the package itself.
I don't know if I am correct just trying to help by providing more information.
Thanks, Oliver :)
java build jar lwjgl classnotfoundexception
add a comment |
I am relatively new to Java, and I have made a script which uses the LWJGL 3. The program runs perfectly fine within the Eclipse IDE but when I attempt to export it as a runnable Jar file (I checked package required libraries field) and then attempt to run it through windows command line I get the error message as follows:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
at renderEngine.TestEngine.main(TestEngine.java:18)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more
I am assuming this is an issue caused by a lack of access to the libraries I imported, but after searching the web for a while I could not find a single proper guided answer to solving the question. Most of the time it was someone asking the question and then just stating they solved it themselves or someone else explaining the issue but not actually assisting with it. I am hoping someone can assist me with a guided explanation of how to fix this issue, and also if it could be explained as to avoid future issues.
If any more information is needed to assist with the issue I will be happy to provide it.
UPDATE:
It seems that the issue is with GLFW and not the library as a whole. As re-reading the error, the only thing that cannot be found or loaded is GLFW when I am also using other imports from the same library such as OpenGL. Also, the line it specifies is the line in which I call a function from GLFW and not when I import the package, don't know if that is because errors don't get called when imports are unsuccessful or if there is another issue possibly within the package itself.
I don't know if I am correct just trying to help by providing more information.
Thanks, Oliver :)
java build jar lwjgl classnotfoundexception
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.
– Oliver
Jan 3 at 0:05
add a comment |
I am relatively new to Java, and I have made a script which uses the LWJGL 3. The program runs perfectly fine within the Eclipse IDE but when I attempt to export it as a runnable Jar file (I checked package required libraries field) and then attempt to run it through windows command line I get the error message as follows:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
at renderEngine.TestEngine.main(TestEngine.java:18)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more
I am assuming this is an issue caused by a lack of access to the libraries I imported, but after searching the web for a while I could not find a single proper guided answer to solving the question. Most of the time it was someone asking the question and then just stating they solved it themselves or someone else explaining the issue but not actually assisting with it. I am hoping someone can assist me with a guided explanation of how to fix this issue, and also if it could be explained as to avoid future issues.
If any more information is needed to assist with the issue I will be happy to provide it.
UPDATE:
It seems that the issue is with GLFW and not the library as a whole. As re-reading the error, the only thing that cannot be found or loaded is GLFW when I am also using other imports from the same library such as OpenGL. Also, the line it specifies is the line in which I call a function from GLFW and not when I import the package, don't know if that is because errors don't get called when imports are unsuccessful or if there is another issue possibly within the package itself.
I don't know if I am correct just trying to help by providing more information.
Thanks, Oliver :)
java build jar lwjgl classnotfoundexception
I am relatively new to Java, and I have made a script which uses the LWJGL 3. The program runs perfectly fine within the Eclipse IDE but when I attempt to export it as a runnable Jar file (I checked package required libraries field) and then attempt to run it through windows command line I get the error message as follows:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: org/lwjgl/glfw/GLFW
at renderEngine.TestEngine.main(TestEngine.java:18)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.glfw.GLFW
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 6 more
I am assuming this is an issue caused by a lack of access to the libraries I imported, but after searching the web for a while I could not find a single proper guided answer to solving the question. Most of the time it was someone asking the question and then just stating they solved it themselves or someone else explaining the issue but not actually assisting with it. I am hoping someone can assist me with a guided explanation of how to fix this issue, and also if it could be explained as to avoid future issues.
If any more information is needed to assist with the issue I will be happy to provide it.
UPDATE:
It seems that the issue is with GLFW and not the library as a whole. As re-reading the error, the only thing that cannot be found or loaded is GLFW when I am also using other imports from the same library such as OpenGL. Also, the line it specifies is the line in which I call a function from GLFW and not when I import the package, don't know if that is because errors don't get called when imports are unsuccessful or if there is another issue possibly within the package itself.
I don't know if I am correct just trying to help by providing more information.
Thanks, Oliver :)
java build jar lwjgl classnotfoundexception
java build jar lwjgl classnotfoundexception
edited Jan 4 at 5:59
Oliver
asked Jan 2 at 4:29
OliverOliver
62
62
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.
– Oliver
Jan 3 at 0:05
add a comment |
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.
– Oliver
Jan 3 at 0:05
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:
java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.– Oliver
Jan 3 at 0:05
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:
java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.– Oliver
Jan 3 at 0:05
add a comment |
1 Answer
1
active
oldest
votes
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001207%2fissue-with-running-jar-file-with-imported-libraries%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
add a comment |
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
add a comment |
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
You can export your project as a 'Runnable jar' (Right mouse on project -> Export -> Runnable jar) you have the option to package all dependencies into the generated jar.
Use highlighted library handling option.
answered Jan 2 at 4:52
Dark KnightDark Knight
6,36942850
6,36942850
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
add a comment |
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
OP has already mentioned that he has created the jar this way.
– Rahul
Jan 2 at 5:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
As Rahul has already mentioned, I created the jar through the way you recommended and have encountered no issues during the exportation.
– Oliver
Jan 3 at 0:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54001207%2fissue-with-running-jar-file-with-imported-libraries%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you have any problem while exporting the program into runnable jar files?
– sharky
Jan 2 at 6:24
No, I have encountered no issues during the export. The issue arose when attempting to run the file through the windows command line using the command:
java -jar FileName.jar
. The error as shown above in the original post is what I received after typing the command.– Oliver
Jan 3 at 0:05