I'm writing an application that makes use of Java's speech API and FreeTTS. The application works fine when I run it from the Netbeans IDE, but when I try to run it from a jar file on my local machine or on other machines, I get the following error:
"java.lang.NoClassDefFoundError: com/sun/speech/freetts/VoiceManager"
Is there any way for me to include the FreeTTS files in my jar file so it can run anywhere?
Any help would be greatly appreciated.
i had the same problem and i found this page:
http://ondra.zizka.cz/stranky/programovani/java/misc/freetts-line-unavailable-classcastexception-kevinvoicedirectory-error-opening-zipfile.texy
I did the easy way, which was to add the freetts installation to my dist folder, change the manifest of my jar on where to find the jsapi.jar, freetts.jar etc. and it is worked. I am just distributing freetts inside my folder.
The hard way is on the link above.
Related
I built a javaFX artifact using IntelliJ. My first problem was in the Application Class box, where it didn't automatically detect my main class, or even suggest any classes as main class when I searched in the search box. I saw that it was a bug with IntelliJ, somewhere on StackOverflow, and I just manually entered my packageName.Main in the application class box.
I have two dependencies that I extracted into this output root. The output of building the artifact looks like this.
Then after rebuilding the project the JAR runs on my PC 100%, even if I move the JAR to another directory, it works 100%.
So I copied this JAR (Swansong.jar) to my other PC and when I double-clicked it, nothing happended. When I ran it in the cmd:
java -jar Swansong.jar I got this error:
Error: Could not find or load main class swansong.Main
Caused by: java.lang.ClassNotFoundException: swansong.Main
I read about manifest files but I can't find a manifest file anywhere in my project, but if I extract the JAR file the manifest file that was generated looks like this. Can anyone please help me, why does the JAR run on one PC but not on the other? And how can I fix this?
UPDATE:
This is the contents of my jar file and this is the contents of the swansong directory inside the jar file.
UPDATE 2:
I feel stupid. My main PC runs jdk8 and my other pc runs jdk11. And JavaFX is not included in the jdk11. So I think this is the problem, but not 100% sure yet. Will test and see. Are there any workarounds for this?
I hate to admit it, but the solution to the problem was staring me in the face all along, and I am truly embarrassed. I used Java 8 to develop the program. Target PC was using Java 11 and I never thought to check the JDK version, because I thought I was using JDK8 on both PCs.
JavaFX is included in JDK8, but not in JDK11. It should be added to a project as an external library when using newer JDK versions. I just used JDK8 for running the program and everything works 100%. Thanks for the answers and comments though, I learned a lot about manifests and classpaths trying to solve this problem, so the effort was not in vain!
Any executable jar file needs to have manifest file which points to the main class.
-JAR File
\---META-INF
\--MANIFEST.MF
In the MANIFEST.MF, you should introduce the main class as this:
Main-Class: com.mycompany.MainClass
Class-Path: .
com.mycompany.MainClass should be replaced with appropriate path (fully qualified name of your main class)
I just can't seem to find the .class files for my Groovy source code in IntelliJ IDEA Grails projekt. I've created a grails app "qotd" and a plugin "selenium" which is kind of a grails app itself, as you might know. So just to keep things tidy here's a screenshot of my Grails View:
Grails View
As you can see I have source code for both Java and Groovy. Both share the same package "de.it2m.testcases". Could this be a problem? Anyway, now I need to know where the .class files are stored. I've compiled both the "qotd" app and its "selenium" plugin using the "grails run-app" command without errors, so I'm sure there must be the .class files somewhere. I already found the class file for the "SeGridTest.java" class in:
...IntelliJ workspace\qotd\out\production\selenium-inplacePlugin\de\it2m\testcases
Unfortunately the "SeleniumTest.class" is missing in this directory (as I would have expected it there). I was browsing the ".grails" directory as well but without any success.
Where could the SeleniumTest.class hide...?
Note: I'm working on Windows 8.1 Pro, IntelliJ ultimate 13.1.4 and Grails 2.3.8
#Tinku Saini
Thanks for your help! The .class files get into the "target" directory
I am trying to setup a java based opencv program to run on raspberry-pi.I installed opencv-2.4.8 on my raspberry-pi. I also installed eclipse to set up opencv.The problem is i am not able to link native libraries for my opencv-2.4.8 jar file in eclipse.
Eclipse is running fine with raspberry-pi and i am able to compile and run simple java programs.From where to link the native library for opencv2.4.8 jar file.
I checked my opencv folder and it is having the following structure.
MY OpenCV Folder
Opencv release folder
Found the following opencv .so files in usr/local/lib folder of my pi. Is this is what i should link to my native library. But there are many .so files also.
The output console with the error is as follows. sorry the screenshot skipped unsatisfied link error..
I had the same error which come up like this. I have an application that I have to run. I build and install opencv and try to run but I see that error like you. For solving this issue I replace old opencv_*jar with built one in opencv directory. You have to use jar file that you have just built.
..../opencv/build/bin/opencv-2410.jar
I thing old jar looks for different native path.
I had the same issue. I set my Native Lib Location to {OpenCV directory}/{Build directory}/lib and things worked fine.
As a newbie to programming, I am finding it really quite difficult to install all the necessary software and such to get everything running.
Up until now I have been using the command prompt and javac along with gedit to edit/compile my code, but we are meant to be using eclipse and then JUnit to test it.
I have just managed to get eclipse working, but still stuck as to how to get JUnit working.
I am stuck on the installation part...
The JUnit FAQ (http://junit.sourceforge.net/doc/faq/faq.htm#started_1) states...
Windows
To install JUnit on Windows, follow these steps:
Unzip the junit.zip distribution file to a directory referred to as %JUNIT_HOME%.
Add JUnit to the classpath:
set CLASSPATH=%CLASSPATH%;%JUNIT_HOME%\junit.jar
How can you "unzip" the "junit.zip distribution file" to the directory "%JUNIT_HOME%" and how do you add something to the classpath? Where is this class path? I tried extracting the zip folder and typing "%JUNIT_HOME%" into the directory, but it says the destination path is invalid, so I assume this is not what the instructions mean.
Apologies for the noob-questions... I'm finding this technical jargon difficult to find my way around.
Any hints for the next steps for installing JUnit will also be appreciated, as I will likely get stuck on those too.
If you are using Eclipse, please import the junit.jar file to your classpath in your project. You can do it by right+click on the project and choose Properties -> Java Build Path. and add you jar file.
I am making a simple Desktop application in java, Build using gradle.I have added log4j jar into my application. App runs in eclipse. But when I run it in my terminal using java -jar xxx.jar it not recognize the log4j. Then I extract my jar file and check is there any log4j.jar files. But I can not find it. I know There is a problem with my build.gradle file. I tried to find it through Internet, But still can not. Any body can help me? How should I write the code to copy libs into my jar file ?
You can refer to these links for the issue http://forums.gradle.org/gradle/topics/how_to_add_jars_into_a_jar
http://forums.gradle.org/gradle/topics/how_do_you_add_jar_libraries_to_your_build