I'm using eclipse RCP (helios), and I need to add statistics functions.
In the editor, I have no problem, no error.
But when I run or debug the project, I get:
java.lang.ClassNotFoundException:
org.apache.commons.math3.stat.descriptive.SummaryStatistics error.
first question, the library says si java 1.5+ compatible, I'm running on 1.6.
is this ok?
besides build path... is there any other way to set classpath ?
Best Regards
Related
I have what is probably a stupid question... but here goes anyway. Some years back, I wrote a "Star Trek" game in Java 8, using JavaFX and Eclipse IDE. The project grew to be fairly large, but it worked. When I finished, I made sure to export the project using Eclipse's File --> Export menu.
I recently grew nostalgic and decided to import the "Trek" project into Eclipse on my current laptop. (The original laptop died.) FYI, my current version of Eclipse is Version: 2018-12 (4.10.0), which I thought was pretty recent.
The project imported just fine, but Eclipse seems mystified by everything in it. For example, when I try to compile and run the project, this error comes up immediately:
Error: Could not find or load main class gameEngine.MainEventTrek
Caused by: java.lang.ClassNotFoundException: gameEngine.MainEventTrek
gameEngine.MainEventTrek contains the project's main() method. Eclipse can't find it??? But the java file is right there, right in the project's src directory:
That's not all. When I open the Java files, Eclipse seems ignorant of how to import common packages:
Look at that; Even line 1 has an error! ("The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files") I can understand that Eclipse might not know about JavaFX - I can't remember if I installed it - but Eclipse doesn't seem to know about common packages like java.math and java.util. Heck, later in my code, Eclipse doesn't know what the System package is, so all my System.out.println() commands are now throwing errors.
I'm a fairly good Java coder, but I'm pretty stupid when it comes to resolving basic compiler issues like this. Does anyone have any idea what the issue might be and how I go about fixing this? Thanks... and Live Long and Prosper.
I am using Scala IDE 4.4.1.,using the jdk 8.When I try to run a scala program ,getting the error "Error: Could not find or load main class example.Credit" .
I was stuck with the same error a few days ago. In my case, it was an incompatibility of my JDK and the selected target JVM for my Scala project.
To check your current Java version, run java -version on the command line. To check your project JVM target in Eclipse, go to "Project > Properties > Scala Compiler" and check the target JVM (choose the same version as your current Java).
Hope it helps.
You should write object instead of class
I was having the same problem so that is how I came to this link & would like to share my findings. In my case I found that incompatible jars where present due to it was throwing error. After providing correct jar issue was resolved.
I used Scala for Eclipse IDE,
The solution for this could be right click on project and select scala -> Set the Scala Installation, will set the scala path to this project and rebuild the same.
Hope this helps you.
If the above mentioned solutions are already configured in your system and still getting this error then consider reading my answer. When incompatible scala jars are referenced by projects, a red cross mark is shown at project level and no errors are shown in scala files. In this situation scala code doesnt compile and when executed shows the message "error could not find or load main class scala". Best solution is to go to the scala installation folder and to check if the jar is present there, if present then reference it else reference jar files that do not show error (red mark) at project level or at source code.
I recently upgraded to IntelliJ 14, then added Scala support.
My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:
Exception in thread "main" java.lang.ClassNotFoundException: GUI
It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.
I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.
It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.
This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala
Sample View of the problem
I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.
Solution
Turns out that Make, No Error Check does not work the same for scala as it does for Java.
Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.
Fixing the scala files fixes the error.
In my case, the solution was at the JDK and java level.
When I set JDK 14 this error occurred.
So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.
In project(module) settings section: Project, Modules, SDK's
In main method settings: JRE
I have a project that uses both Java and Scala code. When I am trying to run a main function from Scala on Intellij 13.1.4 with Scala Plugin 0.38.441 installed I get the following error
Error:scalac: Error: Scala instance doesn't exist or is invalid:
version unknown, library jar: /home/arpit/.m2/repository/org/scala-lang/scala-library/2.11/scala-library-2.11.jar, compiler jar: /home/arpit/.m2/repository/org/scala-lang/scala-compiler/2.11/scala-compiler-2.11.jar
sbt.InvalidScalaInstance: Scala instance doesn't exist or is invalid:
version unknown, library jar: /home/arpit/.m2/repository/org/scala-lang/scala-library/2.11/scala-library-2.11.jar, compiler jar: /home/arpit/.m2/repository/org/scala-lang/scala-compiler/2.11/scala-compiler-2.11.jar
at sbt.ScalaInstance$.slowActualVersion(ScalaInstance.scala:122)
at sbt.ScalaInstance$.sbt$ScalaInstance$$actualVersion(ScalaInstance.scala:119)
at sbt.ScalaInstance$$anonfun$actualVersion$1.apply(ScalaInstance.scala:32)
at sbt.ScalaInstance$$anonfun$actualVersion$1.apply(ScalaInstance.scala:32)
at scala.Option.getOrElse(Option.scala:120)
at sbt.ScalaInstance.actualVersion$lzycompute(ScalaInstance.scala:32)
at sbt.ScalaInstance.actualVersion(ScalaInstance.scala:32)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$.org$jetbrains$jps$incremental$scala$local$CompilerFactoryImpl$$getOrCompileInterfaceJar(CompilerFactoryImpl.scala:79)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:43)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl$$anonfun$getScalac$1.apply(CompilerFactoryImpl.scala:42)
at scala.Option.map(Option.scala:145)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.getScalac(CompilerFactoryImpl.scala:42)
at org.jetbrains.jps.incremental.scala.local.CompilerFactoryImpl.createCompiler(CompilerFactoryImpl.scala:21)
at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:23)
at org.jetbrains.jps.incremental.scala.local.CachingFactory$$anonfun$createCompiler$1.apply(CachingFactory.scala:23)
at org.jetbrains.jps.incremental.scala.local.Cache$$anonfun$getOrUpdate$2.apply(Cache.scala:20)
at scala.Option.getOrElse(Option.scala:120)
at org.jetbrains.jps.incremental.scala.local.Cache.getOrUpdate(Cache.scala:19)
I also checked for compiler settings under Project setting in IntelliJ and for Scala Compiler it says "Nothing to show here in external build mode". Can this be the problem?
It seems that the compiler cannot read the version of the scala-compiler jar. Maybe it is corrupted. Try to redownload it or to use another version. To set another compiler library go to Project Structure/Facets/Scala facet of your module and select a suitable library.
If it does not work please create a ticket on the bugtracker (with the attached compiler library):
http://youtrack.jetbrains.com/issues/SCL
Also you can try to change the type of the incremental compiler in Settings/IDE Settings/Scala
There is nothing wrong with the Compiler/Scala Compiler settings.
I had the same problem, that's what I've done:
(After installing IntelliJ and SBT) I downloaded Scala as well from this website and installed it.
Then I went to File -> Project Structure -> Libraries and I removed the existing library.
Afterwards, I clicked the "+" symbol and "Scala SDK" and found the Scala installation folder (C:\Program Files (x86)\scala\ in my case).
And followed the instructions. Then everything worked fine...
Hope it helps...
I had similar issue when run Idea under the root user. Idea was not able to find the scala library. I solved the issue by quitting the Idea and run it under my current user.
in my case i went into Compiler/Scala Compiler settings and deleted additional compiler options (make -transitive)
I'm trying to build a simple Drools project in Eclipse, but when I try to test it, a runtime exception is thrown with the message, "The Eclipse JDT Core jar is not in the classpath."
Any ideas where I might find this jar?
Thanks!
Try this:
http://affy.blogspot.com/2008/07/jboss-rules-classpath-error-eclipse-jdt.html
If it's not that, please provide some more info on your problem...