UIMA installation: exception in thread "main" java.lang.classcastexception - java

I am trying to configuire eclipse (in Windows) with UIMA using this tutorial . I have followed each step exactly and finaly am able to import uimaj-example in eclipse with no error. but I am unable to import the UIMA packages in my java class. (The import org.apache.uima.analysis_component cannot be resolved). The project structure is as following:
In UIMA-SDK folder, the read-me suggested to test the installation, run the documentAnalyzer.bat (or .sh) file located in the bin subdirectory.
the documentAnalyzer.sh run just for a moment and then disappears showing this:
(Sorry for the blur image, i wasnt able to take clear screenshot as it appeared only for a second)
I have already
imported UIMA in build path of my project
added UIMA_HOME variable in eclipse java/classpath
set the Enviroment variable path of directory
I am new to Java and UIMA. I might be doing something wrong, clearly. Any suggestion would be very helpful.

Related

netbeans icon ok in designer but fails when run (maven)

So I followed the netbeans (I'm using 12.2) tutorial for handling images:
https://netbeans.org/kb/73/java/gui-image-display.html?print=yes
I can see the icon in the designer but when run getResource() returns a null indicating it can't find the resource.
I have found this question which seemed to be related:
Netbeans ImageIcon not displaying
I have ensured that I am using a package and not a folder.
The error generated :
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at com.byotrader.zom.ZomFrame.initComponents(ZomFrame.java:37)
The line of code:
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/byotrader/zom/resources/ZomIcon.gif"))); // NOI18N
I have no idea why this is failing when run.
So my introduction to netbeans isn't going as smoothly as I hoped!
As requested project screen shot:
https://photos.app.goo.gl/CJ4EB3PD4a86nAVK8
Any ideas what I have failed to do?
One suggested answer relating to the following question :
netbeans & java, resourceMap.getString returning null
However the answer clearly states this is only a problem if a Clean build has not been done. That is not my issue as I have tried a clean build!
However looking in the .jar file I can see the picture resources have not been added! I assume this is the problem. However I have no idea how I can force the IDE to do its job!
Link to files structure:
https://photos.app.goo.gl/bRxHHW2UtRjPF7LeA
This link may also help others in future:
Netbeans Maven Project - Other Sources does not appear
(It is a Maven-Project!*) Put your image under:
src/main/resources/com/byotrader/zom/resources/ZomIcon.gif
../resources/...
Explanation:
Netbeans (when on a maven project) completely (except maybe in designer mode!;) builds with maven! ...which means... no gif (etc.) files are considered form src/main/java ... (check your target/classes folder!)
After my fix proposal, the image should be in the desired location.
* The tutorial(, which explicitly tells "Java Project") is little outdated for Netbeans 12.2, where there is no "Java Project"... possible alternatives are (maven/gradle) "Java Frontend Project" (requires javaFX!) or the "good ole" (ant) "Samples>Java With Ant".

Error "ClassNotFoundException" in IntelliJ IDEA

I made this simple program:
package main.java;
public class start {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
And got this error. I have NO idea what is happening,
"C:\Program Files\Java\jdk1.7.0_21\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_21\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_21\jre\lib\ext\zipfs.jar;C:\Users\Tim\IdeaProjects\Rust\out\production\Rust;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain java.start
Exception in thread "main" java.lang.ClassNotFoundException: java.start
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Process finished with exit code 1
Anyone know what is wrong?
Probably your project structure was src/main/java/start.java but when you added it to IntelliJ you have set src as a source folder, so IntelliJ put main.java as a package.
In Project Setting (Ctrl+Shift+Alt+S) → Modules → Sources tab set src/main/java as Source Folder. Then in your simple program change package to whatever you like (e.g. my.test). After that if IntelliJ reports any error in line with package quick fix with Alt+Enter should help
I had this problem and couldn't solve it with any of these solutions. However I think the problem was that I was using 'open' to create a project from a directory with some java files in. Instead I had to 'create new project' with the same directory as root.
Make sure you delete any '.idea' directories and '.iml' files when 'create new project' since it will otherwise complain about a project already being in the given directory.
Above answers are fine. I would like to add an one more option if someone has any dependency with scope as provided then following configuration is needed.
Run -> Edit Configurations -> Include dependencies with "Provided" scope.
Mark the tick box, apply and run.
In my case the path to the project had some characters such as : \ /
ex: C:\something\other:thing\aaa\project , and that's why it didn't worked. Moving the project to a path that doesn't have those characters fixed the errors.
As mentioned before you should check File → ProjectStructure → ProjectSettings → Modules → Sources - your folder must be marked as a "Source".
Also you should update your Run → EditConfigurations → Configuration → Main class to correspond with your package
Just for the future: I had unicode characters in the folder name like "Course name"/Tehtävät/Project and the problem was in "ä". When i changed it to "a" the program started to work.
For me, in IntelliJ-Idea 2016, the problem was that in Project_structure/modules, in the Path tab you have to check "Inherit project compile output path", rather than "Use module compile output path"
I falled down this problem after a recent re install of my intellif community edition.
IntelliJ IDEA 2016.3.2
Build #IC-163.10154.41, built on December 21, 2016
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
om my laptop asus N73SV with Ubuntu 16.04
The Context is:
I was trying to restart Intellij projects previously running fine. That projects where done with intellij CI, AND THEY WHERE located on my freebox server.
I've tryed all solutions proposed here, but without result.
At the end I just:
Close the project. Shutdown Intellij. copy / paste the entire project from my freebox server to my system folder. Re start Intellij, open the project previously paste into my system folder. Rebuild the projet from the /Build/Re build menu. And finaly Run my project. And !!! DONE...It works!!
My suggest is: Is there a problem with pathname lenght or characters contented in that pathname to the project.
Indeed /run/user/1000/gvfs/smb-share:server=freebox,share=disque%20dur/blaBlaToMyFileProjectFolder
The full pathname contents 127 caracters among :,-_/%=
It that the tric?
Hope it's help.
Sorry for my broken english. I'm french ;-)
Oliver
I also had same problem but I couldn't find solution on web so tried rectifying myself, after reading so many blogs i understood the concept, In my case everything was fine as I have download code from git but my IDE intellij couldn't recognise maven dependencies and that's why intellij was throwing this error, my pom.xml was having all dependencies but still intellij couldn't able to recognise it. I navigated to maven window at right in intellij and added path of the project in which I was working after adding it maven loaded all the dependencies and my code worked fine.So basically only three steps can make you resolve it:
1. Open maven window in intellij.
2. Click "+" and add path where your prjojects pom.xml file is present.
3. Click Enter.
Now you can run your project.
Happy coding!!
Check the scope of the dependency from which the class which is shown in error stack is derived. In my case, the scope was given as provided, when I removed the scope, it worked.
I've got this error when i updated Intellij Idea to 2019.3 and couldn't solve it with any of these solutions. But it solved when i uncheck all profiles in maven window and check proper profile again.
If the error is with external library jars, we need to include them in provided scope.
In Intellij run configuration, modify options - > select Add dependencies with "provided" scope to classpath.
Your package is main.java, you pass the argument com.intellij.rt.execution.application.AppMain java.start, and you exception says that that can not found java.start. And this is correct.
Try to compile it using only console. Leave the IDE for the beginning, invest you time to understand the compiler not how the IDE works.
Rebuild the project. It's that easy. Don't thank

Cannot find the shared library (java.lang.UnsatisfiedLinkError)

I need to run my Eclipse project on a different laptop. The following error occurs when running the code:
Exception in thread "main" java.lang.UnsatisfiedLinkError: The shared library C:\Archivos de programa\ECLiPSe 6.0\lib\i386_nt\ec_java_load.dll could not be found.
How can I configure the correct path to "ec_java_load.dll"? It should be "C:\Program Files..." instead on the current one.
I see this a lot when moving eclipse projects around. I also see eclipse mentioned in your error string, so I think I'm on the right track.
To fix this, you have to go into the project settings - build path, remove the old non-working lib and add the right one for the environment you are in

Eclipse can't find / load main class

My Eclipse (Indigo) was running just fine. I created a simple class Hello. It is placed in package cont in the folder ch13. However, when I try to run it from Eclipse I get info from Java Virtual Machine Launcher:
Could not find the main class: cont.Hello.
I tried to run other classes from this package and they run just fine (that is the classes that existed there before). However any new class I create in this package has these problems. Actually any new class I create in Eclipse runs into this problems. I decided to check how it works from the command line. It seems that the problem still exist - I get same error. I checked the path and it is C:\Program Files\Java\jdk1.7.0_02\bin, which is correct (note the other classes are running from Eclipse just fine). I tried to run with java -cp . Hello and there are some Errors produced starting with java.lang.NoClassDefFoundError: Hello (wrong name: cont/Hello). Code itself is simple:
package cont;
public class Hello {
public static void main(String[] args){
System.out.println("Hello");
}
}
How can I fix it so that my classes still run under Eclipse?
.metadata is corrupted.
Steps:
Warning: Deleting .metadata will delete all your Eclipse configurations, plugins, project setups. Make a backup before you attempt this!
Stop eclipse, delete .metadata in workspace and restart eclipse
Import Project
Run again
Removing the Run Configuration
Sometimes I have a similar problems in some pre-release versions of eclipse. For fix the error, I delete the Run Configuration. You can find that in menu Run, Run Configurations...
Then I launch the app with Alt+Shift+X, then J. If this don't work, Ctrl+F11.
Deleting the .metadata directory
In another way, the configuration settings for your current workspace may are corrupted. Those settings are in the .metadata directory in your current workspace 1. In that case, there is no other choice than delete the directory:
Close eclipse.
Delete the .metadata directory.
Start eclipse.
Import the projects.
Run the project again.
Notes
You will see that directory with File > Switch Workspace > Other...
I have solved the issue following way:
Go to Run Configuration (Right Click on Java File->Run->Run Configuration).
Go to ClassPath Tab:
Click on Advanced -> Add Folders -> Add bin directory (which has class file in it for Java source code)
Re run the code, now it will solve the issue. It worked for me
Note: This worked in the past and I received many up votes. Perhaps this is not a solution anymore - but it once was - as the eclipse version was indicated.
Problem
This can also be caused by a Java Build Path Problem.
In my case, I had a an error:
A cycle was detected in the build path of project {project}. The cycle consists of projects {x, y, z}.
This can occur when you include other projects in the build path of the project you wish to run. In fact, all the projects will fail to run with the error
Could not find the main class: Example.class
Solution
Open
Windows -> Preferences -> Java-> Compiler -> Building -> Build Path Problems
Uncheck the Abort build when build path errors occur toggle
This seems like a can of worms if you end up with other build path errors I image. So use with caution.
Note: This only works if you have a "cycle error". This error message can be found in the "Markers" tab
I found the solution to this here
Info
Java 1.8.0_152
Eclipse Photon (June 2018)
Renaming the main class should be enough (and easiest):
- Go to your class and set cursor to your class name;
- ALT + Shift + R and rename the class (build if not done automatically);
- You should be able to run it now;
- Rename the class to the old name if you want;
You must have main function in your class. Like
public class MyDataBase {
public static void main(String args[]) {
}
}
I had this same problem in a Maven project. After creating the src/test/java folder within the project the error went away.
Another tip: I initialized static fields in a wrong order - surprisingly it didn't bring up a Problem (NullPointerException?), instead Eclipse complained with exactly the message OP posted. Correcting the static initialization order made the class run-able. Example:
private static ScriptEngineManager factory = null;
private static ScriptEngine engine = null;
static {
engine = factory.getEngineByName("JavaScript");
// factory is supposed to initialize FIRST
factory = new ScriptEngineManager();
}
I found the way to fix this problem was to rename the project. If you give it a name with strange characters (in my case, :), it will have trouble locating your class. I don't know if this rule applies to numbers, but try renaming the project or making a new one and copying the files. Name it without any numbers or special characters.
I solved this error by closing the project, removing it from eclipse and then importing it again.
Might be a little simpler than to redo the whole workspace setup.
I had this issue after upgrading to the Eclipse 2019-12 release. Somehow the command line to launch the JVM got too long and I had to enable the jar-classpath option in the run configuration (right click on file -> run as -> run configs).
I read so many blogs and tried so many tricks but my problem not resolved. I was able to run the code but not able to generate the jar file. :( Sad..
But I tried something which might be very silly but worked for me and bought eclipse on trace. What I did was..
Just deleted the main method from the class. Saved it. Did undo to bring the main class back. Tada... Issue resolved...
Just one think would like to say, keep your eclipse in "Build Autometically" mode.
Move your file into a subdirectory called cont
Standard troubleshooting steps for Eclipse should include deleting and re-importing the project at some point, which when I have dealt with this error has worked.
I solved my issue by doing this:
cut the entire main (CTRL X) out of the class (just for a few seconds),
save the class file (CTRL S)
paste the main back exactly at the same place (CTRL V)
Strangely it started working again after that.
It is possible to have 2 groovy-xxx-all.jar files by excample in lib directory. which makes that an app is not running
I had the same problem, this is my solution:
I manually deleted the bin folder of the project
Then I refreshed the project which recompiled the whole project and created a new bin with all .class files
I did it because when I performed Clean(project->clean) my .class files were not getting deleted. the above solution works for me hope its useful to others.
I had the same problem.I solved with following command maven:
mvn eclipse:eclipse -Dwtpversion=2.0
PS: My project is WTP plugin
If you are using a pre-defined run configuration, go to classpath and try "Restore Default Entries". This will reconfigure the classpath for that configuration.
This worked for me finally :
RUN -> RUN CONFIGURATIONS -> DELETE THE RUN CONFIGURATION
CLOSE ECLIPSE
REOPEN ECLIPSE
CREATE RUN CONFIGURATION AGAIN.
Tadaaaa !! It works

UnavailableServiceException on lookup for "javax.jnlp.BasicService"

UnavailableServiceException is being thrown on look-up for javax.jnlp.BasicService.
Below is the code snippet:
BasicService basicServiceHandle =
(BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
I am just trying an example of jnlp API - BasicService # http://pscode.org/jws/api.html#bs as a Java Application.
Any suggestions as to what could be the reason for the same... or anything that could be worth checking?
Update
I am not sure how I should be trying it from eclipse.
..not sure how I should be trying it from eclipse
File|New|Java Project
Project name: BasicService|Finish
File|Import
General|Archive File|Next
From archive file: basicservice.zip (Into folder: BasicService)|Finish
In the 'Package Explorer', navigate to: BasiceService/basicservice/build.xml
Ctrl+F11 (Run)
Ant Build|OK
(Follow the prompts)
There may be better ways. That as shown is just what I figured out from having downloaded Eclipse and doing a bit of a crash/bang through the help.

Categories