I have project which I need to modify for a task and that runs a terminal with the help of a .jar file. I can run the very same Code on an IDE like Eclipse, but not VSC.
This is the error is get:
The jar files for this project are:
text-io-3.4.0.jar, slf4j-api-2.0.0-alpha5.jar and slf4j-nop-2.0.0-alpha5.jar
Exception in thread "main" java.lang.NoClassDefFoundError: jline/console/ConsoleReader
at org.beryx.textio.jline.JLineTextTerminalProvider.getTextTerminal(JLineTextTerminalProvider.java:28)
at org.beryx.textio.TextIoFactory$Holder.getDefaultTerminal(TextIoFactory.java:95)
at org.beryx.textio.TextIoFactory$Holder.<init>(TextIoFactory.java:65)
at org.beryx.textio.TextIoFactory$Holder.<clinit>(TextIoFactory.java:54)
at org.beryx.textio.TextIoFactory.getTextIO(TextIoFactory.java:111)
at ch.zhaw.catan.Catan.run(Catan.java:19)
at ch.zhaw.catan.Catan.main(Catan.java:50)
Caused by: java.lang.ClassNotFoundException: jline.console.ConsoleReader
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 7 more
I assume it's about configurations. The path to the library is set within the project. I don't see the error, my professor doesn't use VSC.
What can I do to fix this? Do I need to provide more data? I could upload the files if needed.
-edit
here's a link to the dummy.java and the jar files
https://github.com/dangdung87/test
as for the lines causing the error:
private void run() {
TextIO textIO = TextIoFactory.getTextIO();
TextTerminal<?> textTerminal = textIO.getTextTerminal();
It appears that the textio lib needs the jline library (https://mvnrepository.com/artifact/jline/jline/2.14.6).
Download the jar and add it to the dependencies of the project.
We had the same problem with the catan project ;)
I did found quite a lot about this error, but somehow none of the suggested solutions resolved the problem.
I am trying to use JNA bindings for libgphoto2 under Ubuntu in Eclipse (moderate experience with Java on Eclipse, none whatsoever on Ubuntu, I'm afraid). The bindings in question I want to use are here:
http://angryelectron.com/projects/libgphoto2-jna/
I followed the steps described on that page, and made a simple test client that failed with the above error. So I reduced the test client until the only thing I tried to do was to instantiate a GPhoto2 object, which still produced the error. The test client looks like this:
import com.angryelectron.gphoto2.*;
public class test_class
{
public static void main(String[] args)
{
GPhoto2 cam = new GPhoto2();
}
}
The errors I get take up considerably more space:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Structure
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test_class.main(test_class.java:12)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Structure
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
libgphoto2 itself is installed, it runs from the command line, I even have the development headers and am able to call GPhoto2 functions from python, so the problem can't be located there.
When looking at the .class files in Eclipse, however, they didn't have any definitions. So I figured that might be the problem, especially since there was an error when building the whole thing with ant (although the .jar was succesfully exported, from what I could make out the error concerned only the generation of documentation).
So I loaded the source into eclipse and built the .jar myself. At this occasion Eclipse stated there were warnings during the build (though no errors), but didn't show me the actual warnings. If anyone could tell me where the hell the build log went, that might already help something. I searched for it everywhere without success, and if I click on "details" in eclipse it merely tells me where the warnings occured, not what they were.
Be that as it may, a warning isn't necessarily devastating, so I imported the resulting Jar into the above client. I checked the .class files, this time they contained all the code. But I still get the exact same list of errors (yes, I have made very sure that the old library was removed from the classpath and the new ones added. I repeated the process several times, just in case).
Since I don't have experience with building jars, I made a small helloworld jar, just to see if I could call that from another program or if I'd be getting similar errors. It worked without a hitch. I even tried to reproduce the problem deliberately by exporting it with various options, but it still worked. I tried re-exporting the library I actully need with the settings that had worked during my experiment, but they still wouldn't run. I'm pretty much stuck by now. Any hints that help me resolve the problem would be greatly appreciated.
In addition to what #Paul Whelan has said. You might have better luck by just get the missing jar directly.
Get the missing library here, set the classpath and then re-run the application again and see whether it will run fine or not.
What version of java are you using com/sun/jna/Structure may only work with certain JVMs.
In general, packages such as sun., that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun. packages are not 100% Pure Java.
More details here
Your jar needs a MANIFEST.MF which tells your application where the library is found. Create the file in you project root-directory in eclipse and add the following lines:
Manifest-Version: 1.0
Class-Path: <PATH_TO_LIB__CAN_BE_RELATIVE>.jar // e.g Class-Path: ../test.jar
<empty line>
Right-click your project in eclipse, go to Export->next->next->next->Use existing manifest from workspace, select it and click on finish. This should work.
Another solution is to compile the classes into the jar itself with Maven.
This must seem like an idiotic question but I am new to Hadoop and was trying to run a simple example. However, I keep running into problems with JAR files and dont seem to have the correct imports. I am using cloudera CDH 4 and it has a hole lot of JAR files to choose from with several versions of each. Since I am just starting off am not being able to differentiate. Presently i am getting this exception :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration
at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:38)
at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:36)
at org.apache.hadoop.security.UserGroupInformation$UgiMetrics.create(UserGroupInformation.java:120)
at org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInformation.java:236)
at org.apache.hadoop.mapreduce.task.JobContextImpl.<init>(JobContextImpl.java:72)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:144)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:131)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:139)
at com.ayon.hadoop.firstimpl.Driver1.main(Driver1.java:23)Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 9 more
It is probably because of a wrong JAR file import. So my question is this:
Can anyone tell me what are the basic JAR files needed to start up a simple Hadoop job? Also any pointers to the above exception will be much appreciated.
To include all the necessary jar files, compile your code using the following command:
# javac -cp `$HADOOP_HOME\bin\hadoop classpath` YourClassFile.java
Please note the quotes
If you're using Eclipse, follow below steps to add JARs to your project
1.Right click on the project
2.Go to Properties
3.Click on "Java Build Path"
4.Libraries Tab
5.Add External JARs
6.Select the path "/usr/local/hadoop"
7.Select all "JAR files" & add all JARs
8.Again "Add EXternal JARs"
9.Go to path "/usr/local/hadoop/lib"
10.ADD all JARs in there
11.Click "Ok"
You're set. Hope this helps.. again it depends on the Eclipse version you're using.
My java program which I created could not recognize SAPJCO3.jar which is already in the system class path and included in eclipse/project with buildpath option available in eclipse.
ERROR MESSAGE
java.lang.ClassNotFoundException: No ClassLoaders found for: com.sap.conn.jco.AbapException
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/sap/conn/jco/AbapException
If I just remove AbapException from my program and give normal java exception , it throws error on the next JCO class. The same program works good in NETBEANS which I used for testing. Since my actual project was developed in eclipse I need the program to run in Eclipse.
Can any one help me with this.
Try adding the property to your windows "System variables"/"Environment variables".
Variable Name: java.library.path
Variable Value: C:/SAPJCo
This will work for Eclise.
Good Luck!!
I was trying to install the PMD plugin to my IntelliJ IDE. I have followed the instructions but when trying to run the pmd check I am getting the following exception. From what it seems the “.” Is being parsed as a / which produce a wrong file name for the class loader.
Meaning the path: Even though the settings are
-cp %CLASSPATH%; C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4.2.5.jar; C:\Development\IDE\Utils\PMDPlugin\lib\asm-3.1.jar; C:\Development\IDE\Utils\PMDPlugin\lib\jaxen-1.1.1.jar net.sourceforge.pmd.PMD "$FilePath$" ideaj unusedcode,imports "$Sourcepath$" $FileClass$.method $FileName$
From some reason it is still looking for C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4/2/5/jar
Here is the exception:
java.lang.NoClassDefFoundError: C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4/2/5/jar;
Caused by: java.lang.ClassNotFoundException: C:.Development.IDE.Utils.PMDPlugin.lib.pmd-4.2.5.jar;
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4.2.5.jar;. Program will exit.
Exception in thread "main"
I am using Intelli IDEA 10.0.3
Build #IC 103.288 built on April 2011
JDK 1.6.0_21
Do you have any advices?? Thanks
Looks like you have spaces between your CLASSPATH entries. That won't do; remove them.
UPDATE:
I downloaded PMD and managed to make it run. I followed the directions that you posted, replacing the path to PMD with my own. I'd recommend not using a path that has spaces in it.
The one thing that was balky was %JAVA_HOME%, so I replaced it with the hard-wired path to my Java /bin. Once I did that, all was well.
I'd ask why you think PMD is better than the inspector tools built into IntelliJ? I'd rather check boxes to set rules than have to do all the nonsense that PMD requires.
Once I was satisfied that I could make it work I deleted it. I'd rather run Inspector.