java: "Unable to access jarfile ..." - java

I have downloaded RoboMind (http://robomind.net) and try to make it run on a Linux Mint12
Knowing that Min12 is not the newest release, I still would like it to run...
When I use the .sh file that comes in the pack I get an error:
"Unable to access jarfile ..."
if I type the exact same command at the same prompt, in the same directory, it works:
here is a copy paste from the commanline:
magnus#martin-HP-625 ~/Downloads/RoboMind $ ./robomind.sh
Unable to access jarfile RoboMind.jar
magnus#martin-HP-625 ~/Downloads/RoboMind $ cat ./robomind.sh
java -jar -Djava.ext.dirs=lib -Dsun.java2d.ddscale=true -Dsun.java2d.noddraw=true RoboMind.jar
magnus#martin-HP-625 ~/Downloads/RoboMind $ java -jar -Djava.ext.dirs=lib -Dsun.java2d.ddscale=true -Dsun.java2d.noddraw=true RoboMind.jar
java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1076)
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1053)
at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1347)
at robo.RoboMind.startGui(RoboMind.java:168) ... <snip>
Now it works ... ?
Whats the difference?
I messed around with javapath etc. as suggested in other posts, but nothing makes any difference to the situation illustrated above.
Why can't the .sh script find the .jar file when the exact same command at the prompt have no problems?

I'll give you the "solution", and I will let you discover "why".
Just launch:
# dos2unix robomind.sh
..after then it will work. If you do not have dos2unix installed, apt-get install dos2unix

Related

run executeable jar with a linux script

I wrote a little java program and now I want to execute this .jar file from a .sh script.
my script:
#! /bin/bash
java -jar /var/spool/sms/sentSMS.jar
then i run the command: sudo bash sentSMS.sh
an get following error:
ERROR: Unable to access jarfile /var/spool/sms/sentSMS.jar
I am using a Raspberry with raspian-jessie, if this important to solve it.
Sorry, but I'm new in scripting with linux.
Take into account that the user must have at least READ permissions on that file.
Also, as you say you are new in linux, make sure the name is correct. sentSMS.jar is different from sentsms.jar

Trying to execute jar using cygwin, arguments not recognized

I have a makefile that calls a java parser to process some files before compilation. While in linux works perfectly when I am running that on a Windows 7 machine using cygwin my input are recognized as jar files.
My command inside my make is something like
java -jar ${MY_DIR}/myParser.jar -arg1 -arg2 -arg3 input.file output.file ;\
and I get an error that input.file is not a valid jar file... I assume it has something to do with my paths and how cygwin handles java but I can't make it work.
Thanks in advance
Try putting up ()
exec java -jar $(cygpath -w /path/to/myParser.jar) -arg1 -arg2 -arg3 input.file output.file
Srry not enough rep to add comment .

running WEKA on Linux

I am trying to run weka on linux server.
The steps I followed as listed below:
1. I download a zipped archive containing Weka as given on http://www.cs.waikato.ac.nz/ml/weka/downloading.html
I then unzipped the zip file.
I next tried executing weka.jar using the command:
java -Djava.awt.headless=true -jar weka.jar
I also simply tried: java -jar weka.jar
This also gives me errors.
I have set the DISPLAY variable using setenv DISPLAY localhost:0.0.
I have tried other values too such as DISPLAY 0
weka.jar has also been added to the PATH variable.
The error I am getting is as follows:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:433)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.<init>(JFrame.java:202)
at weka.gui.LogWindow.<init>(LogWindow.java:252)
at weka.gui.GUIChooser.<clinit>(GUIChooser.java:215)
Could not find the main class: weka.gui.GUIChooser. Program will exit.
Any help would be appreciated.
Thank You
Perhaps you need to add the CLASSPATH. For example:
java -cp "$CLASSPATH:./weka.jar" -Xmx500m weka.gui.explorer.Explorer
Google told me to run this command :
sudo apt-get install openjdk-6-jre
When I did as following, it worked.
Extract weka.jar to directoy named weka.
Write a script runWeka.sh:
#! /bin/bash
WEKA_HOME="~/weka";
java -classpath $WEKA_HOME weka.gui.Main
Run this script.

Java -cp on linux

I made a program which runs fine on windows. When I moved it over to CentOS, I got this error:
Error: Could not find or load main class org.wbc.WBCController
This is the file setup and .sh on linux:
And this is the file setup and .bat on windows:
Does anybody know what the problem is, and how I can fix it?
Java will respond with this error even if it cannot find the file wbc.jar. I am guessing that that is your problem. You might want to see that your are executing the shell script from within the right working directory.
Check to see if you can run wbc.sh from the console or put this in wbc.sh to make sure it searches for the jar in the same directory as the shell script:
#!/bin/sh
java -cp `dirname $0`/wbc.jar org.wbc.WBCController

Having Problems Getting FreeTTS and JSAPI Working

First off I'm on Ubuntu linux if that matters.
I have a simple project idea based off of FreeTTS and the JSAPI (Java Speech API)
I've downloaded and unpacked FreeTTS and run their build script. Then tried compiling my code linking several jar's required in the lib directory into the class path like this:
javac -cp /home/travis/Desktop/freetts-1.2/lib/jsapi.jar:/home/travis/Desktop/freetts-1.2/lib/freetts.jar HelloUnleashedReader.java
Which then compiles to java bytecode just fine.
However when I run:
java HelloUnleashedReader
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/speech/EngineModeDesc
Any help on this issue would be greatly appreciated as there are many sites around the net discussing problems with getting it to work but not many that discuss their solution.
I see that you are using Ubuntu. You must agree to the binary license before you can use jsapi.jar. You agree to this license in the process of unpacking it. To unpack jsapi.jar in Ubuntu you would type the following:
cd ~/Desktop/freetts-1.2/lib
chmod +x ./jsapi.sh
./jsapi.sh
if you receive a message like
"./jsapi.sh: 1428: uudecode: not found"
then install uudecode with
sudo apt-get install sharutils
and try again
You need to add the jsapi.jar into your classpath. The jsapi.jar can be unpacked by running lib/jsapi.exe inside the freetts installation directory.
I got this error despite I had jsapi.jar on classpath.
java -cp `ls *.jar | awk '{ORS=":";print}'` -jar WebStartClock.jar
What helped me was specifying the main class explicitely:
java -cp `ls *.jar | awk '{ORS=":";print}'` JSAPIClock
Probably something wrong in the JAR metadata or so.

Categories