I created a new project and a new class in eclipse in my ubuntu machine to write the simple Hello World program. It works fine as long as i write the main method and use System.out.println to print my "Hello World". but i want to use the acm.jar package so I imported it to my project and tried to extend the ConsoleProgram class in acm.jar but once i write the public void run() method and try to run it i get some error
i know that i have imported acm.jar successfully because eclipse suggested the rest of the import when i was typing import acm.program.*;
here is the results i get:
Exception in thread "main" java.lang.NoClassDefFoundError: sun.applet.AppletViewer
at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/bilm3z/workspace/xbSampleProject1/bin/,file:/home/bilm3z/workspace/acm.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at gnu.java.lang.MainThread.run(libgcj.so.90)
here is a snapshot of the situation:
http://www.mypicx.com/12302009/situation1/
It follows from your stack trace that you're using a GCJ JVM. Try installing the Sun JVM - there are instructions here. (Note that you might have to enable different repositories for this, and note the update-java-alternatives command.)
After you install the Sun JVM, update your Eclipse preferences according to Bozho's answer, so that your Eclipse uses the correct JVM.
That's strange. Try Right click on your project > Build path > Configure built path > libraries, remove the JRE / JDK from there (if it exists), and add it anew - Add library > JRE System Library
Related
I'm trying to setup libpostal/jpostal on my Windows 10 machine in a Java environment. I followed the Windows Installation Guide on GitHub.
I am able to see the libpostal folder installed under: C:\xxx\Program Files\libpostal\ with sub folders: .git, autom4te.cache, data, m4, resources etc.
However, when I run:
AddressExpander expander = AddressExpander.getInstance();
I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpostal_expander in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.mapzen.jpostal.AddressExpander.<clinit>(AddressExpander.java:7)
at jpostal.JPostal.execute(JPostal.java:24)
at global_projects.GlobalMain.main(GlobalMain.java:37)
I normally use Maven for my build. However, since there is currently no Maven repository for JPostal, I am using Gradle.
I followed the solution suggested on this GitHub thread by adding the following gradle.build file, however I still get the same error.
What am I doing wrong?
I'm going through a Java course, using Intellij IDEA. In this "Test" project, I have only two test classes as shown below (they really don't have any code).
Before I get into the problem, I just need to state that all my projects run correctly, it's just that I have the following problem with running the terminal command, and I'm afraid I messed something up with my IDE:
The problem occurs when I need to get the serial version of the class BankAccount using the following command:
E:\Software Projects\Test\out\production\Test>serialver com.company.BankAccount
I get the error that is shown below, and I understand that the classes were compiled by a newer Java Runtime error, but how do I troubleshoot this in Intellij? I get the same error when running the command on any class in any project.
Additional note: I also get an error related to this one when running the Main class in terminal using java com.company.Main
What I think could be the cause of the problem: Prior to even trying "serialver" for the first time, I changed the name of a project folder (I just used "Rename" in my file explorer in Windows, and it messed everything up in Intellij (whatever project I opened, it had no SDK and no Run/Debug Configurations). So, I selected "Add SDK" on a project (or something similar, and selected a JRE 12 from the list.
Then I ran "Debug Main" and the Run/Debug Configurations were set automatically.
When I go to Project Structure > Project Settings > SDKs I only have one SDK :"C:\Program Files\Java\jdk-12.0.1".
When I go to "Run/Debug Configurations" in a project, in the JRE of Application > Main I have the following to select (but as far as I understand, these are all one and the same SDK, right?):
Default (12 - SDK of 'Test' module)
12(java version "12.0.1")
"C:\Program Files\Java\jdk-12.0.1"
So I don't know how I can adjust anything here? How was I able to compile these classes at a newer Java Runtime version at any point?
The problem here is that I'm not sure if something else is wrong, or if the prior adjustments I've made have messed something up.
The classes:
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
}
}
package com.company;
public class BankAccount {
}
When running
E:\Software Projects\Test\out\production\Test>serialver com.company.BankAccount
What I get in the terminal is the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/company/BankAccount has been compiled by a more recent version of the Java Runtime (class file version 56.
0), this version of the Java Runtime only recognizes class file versions up to 55.0
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at jdk.compiler/sun.tools.serialver.SerialVer.resolveClass(SerialVer.java:108)
at jdk.compiler/sun.tools.serialver.SerialVer.serialSyntax(SerialVer.java:80)
at jdk.compiler/sun.tools.serialver.SerialVer.main(SerialVer.java:188)
Error when running the Main class with E:\Software Projects\Test\out\production\Test>java com.company.Main:
Error: LinkageError occurred while loading main class com.company.Main
java.lang.UnsupportedClassVersionError: com/company/Main has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Run java -version in the command line. If it's not Java 12 or later, it will explain the issue. You are targeting Java 12 version while run it on an older Java version.
The solution would be to either adjust the target language level so that your code can run on older Java versions or to adjust your PATH environment so that java from JDK 12 install directory is the first. Or you can specify the full path to java.exe in the command line when trying to run the code:
E:\Software Projects\Test\out\production\Test>"C:\Program Files\Java\jdk-12.0.1\bin\java.exe" com.company.Main
Solved by editing file "idea.properties" and setting proper JVMVersion
I'm trying to use semantic vectors. Here are some links:
https://code.google.com/p/semanticvectors/wiki/InstallationInstructions
https://code.google.com/p/semanticvectors/
Anyway, I'm on the step where you input java pitt.search.semanticvectors.BuildIndex, but I'm lacking results.
The current part I'm following is "To Build and Search a Model".
I am able to compile the package successfully with the ant command and I did get the first step working with first setting the class path with:
export CLASSPATH=./lib/lucene-core-3.6.2.jar:./…
And then inputing
java org.apache.lucene.demo.IndexFiles -docs .
However with this next step I'm getting these errors:
user:/home/data/SemanticVectors/semant… java pitt.search.semanticvectors.BuildIndex
Exception in thread "main" java.lang.NoClassDefFoundError: pitt/search/semanticvectors/BuildIndex
Caused by: java.lang.ClassNotFoundException: pitt.search.semanticvectors.BuildIndex
at java.net.URLClassLoader$1.run(URLClassLo…
at java.security.AccessController.doPrivile… Method)
at java.net.URLClassLoader.findClass(URLCla…
at java.lang.ClassLoader.loadClass(ClassLoa…
at sun.misc.Launcher$AppClassLoader.loadCla…
at java.lang.ClassLoader.loadClass(ClassLoa…
Could not find the main class: pitt.search.semanticvectors.BuildIndex. Program will exit.
I am using a terminal on a mac OS X
As I see your post, it appears you are not providing a path to the semanticvectors-x.x.jar file as indicated in
export CLASSPATH=./lib/lucene-core-3.6.2.jar:./…
Once this change is done, it should work.
So I'm quite new to eclipse (first week of actually trying to use it to develop stuff.) and I tried to import an example project from http://unfoldingmaps.org/ and upon trying to compile their test project I'm greeted with the error:
Eclipse Error: Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
Right now my $path sys var looks like this:
C:\csvn\Python25\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\MySQL\MySQL Server 6.0\bin; %JAVA_HOME%;%ANT_HOME%\bin
Is there something that I'm missing? Jogl.jar is in the project but it seems like the project is just skipping over stuff.. help?
It seems that your application requires some sort of native library, you need to specify the parameter -Djava.library.path=/path/to/libs on the VM args field on eclipse.
I have configured JDEE in emacs. But when I try to run any App, it throws NoClassDefFoundError .
Upon compilation, although a class file is created, it only shows the buffer for sometime and then closes it.
The same files if compiled and run from the terminal work perfectly fine.
Also, on this machine I have java-6-openjdk installed. I had configured JDEE on my home computer which has sun java jdk and there are no such problems there.
Other than this, features such as code completion, generation etc work fine.
How do I solve this? Is this due to open jdk ?
I am using a Ubuntu 10.04 desktop.
This is the stack trace
cd /home/vineet/java/KodeJava/src/org/kodeplay/kodejava/
/usr/lib/jvm/java-6-openjdk/bin/java org.kodeplay.kodejava.EmacsTest
Exception in thread "main" java.lang.NoClassDefFoundError: org/kodeplay/kodejava/EmacsTest
Caused by: java.lang.ClassNotFoundException: org.kodeplay.kodejava.EmacsTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.kodeplay.kodejava.EmacsTest. Program will exit.
Process org.kodeplay.kodejava.EmacsTest exited abnormally with code 1
Thanks
something in your config is wrong. you are trying to run from the "/home/vineet/java/KodeJava/src/org/kodeplay/kodejava/" directory, but in order to find your class on the classpath, you should be running from "/home/vineet/java/KodeJava/src/". Probably need to configure the "jde-run-working-directory" variable.
From the question, it sounds as if the JDEE configuration is not complete when it comes to setting up the command to be launched when running the Java App.
If the same Java App can be run from the terminal with no issues, OpenJDK is not causing the trouble, I'd wager.
Perhaps you copied over from the other computer the JDEE configurations and did not adopt them for the new computer that has OpenJDK.