marytts.exceptions.MaryConfigurationException: Cannot start MARY server - java

I am trying to get Mary TTS working using Java with Eclipse. I have followed the tutorial from here so far https://www.youtube.com/watch?v=OLKxBorVwk8, but when I try to run the Hello World program it gives me the "Cannot start MARY server". My main code can be seen below:
package model;
public class Main {
public static void main(String[] args) {
TextToSpeech tts = new TextToSpeech();
tts.speak("Hello World!", 1.0f, false, false);
}
}
The classes TextToSpeech.java and AudioPlayer.java can be found here and here, respectively.
The few other threads I found on GitHub on this problem seemed to suggest that too many jar files have been packed into the big jar file but I tried with the jar files from the marytts GitHub page and got the same error. Any help is greatly appreciated.

I have the same problem, but to solve it, I only add the following jar in my project.
guava-22.0.jar
marytts-builder-5.2-jar-with-dependencies.jar
marytts-lang-en-5.2.jar
voice-cmu-rms-hsmm-5.2.jar
voice-cmu-slt-hsmm-5.2.jar
voice-dfki-poppy-hsmm-5.2.jar

Related

How to load video in OpenCV (Java)

I'm trying to load a video file in OpenCV Java, and have narrowed down my issue to the following code:
import org.opencv.core.Core;
import org.opencv.videoio.VideoCapture;
public class OpenCVTest {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.loadLibrary("opencv_videoio_ffmpeg455_64");
VideoCapture capture = new VideoCapture("myVideoFile.avi");
System.out.println(capture.isOpened());
}
}
Of course, this always prints out "false". Accessing my computer's camera with new VideoCapture(0) works fine. After scouring the internet, I'm thoroughly confused as to why loading a video won't work. I followed guides that suggested I needed to add "opencv_videoio_ffmpeg455_64.dll" to my path variable and call System.loadLibrary. I'm new to this, and to be honest, I don't understand what loadLibrary does, or what could be wrong with my setup and code. Any ideas? Thanks in advance.
Here is the answer from similar problem
load the ffmpeg library System.loadLibrary("opencv_ffmpeg300_64");
Open the file:
VideoCapture vC = new VideoCapture("res/video.mp4");
Copy opencv_ffmpeg300_64.dll from opencv\build\x64\vc11\bin to
opencv\build\java\x64
Please note that 64 and .dll may differ from an OS to another, those are for Windows x64
As it turns out, I was using the wrong file path. I (wrongly) assumed that new VideoCapture("my file") would search for "my file" in the directory where the compiled .class files are placed, when in fact it searches in the project root directory. There is no need to call System.loadLibrary("opencv_videoio_ffmpeg455_64");

How to fix a NullPointerException error when running a program with becker.jar as an external jar?

I am setting up a program for a class I am taking. All the code has been provided and I have configured everything into Eclipse. I also had to use becker.jar as an external jar file in the Libraries -> Classpath. When I run the program an error occurs about a NullPointerException.
I already tried changing the becker.jar into the modulepath instead of classpath but then Eclipse cannot find the file. I also tried reinstalling becker.jar as well as redoing the entire setup for the project.
Here is the code I am trying to set up:
import becker.robots.*;
/*
Starting Template:
This file was created in order to provide you with a pre made
'starter' program
*/
public class Starting_Template extends Object {
public static void main(String[] args) {
City toronto = new City();
Robot jo = new Robot(toronto, 3, 0, Direction.EAST, 0);
new Thing(toronto, 3, 2);
jo.move();
jo.turnLeft();
}
}
When running this error shows up:
Exception in thread "main" java.lang.NullPointerException
at java.desktop/sun.font.FontDesignMetrics.getDefaultFrc(FontDesignMetrics.java:158)
at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:279)
at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1183)
at java.desktop/javax.swing.JComponent.getFontMetrics(JComponent.java:1646)
at java.desktop/javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:245)
at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
at java.desktop/javax.swing.JSlider.updateLabelUIs(JSlider.java:853)
at java.desktop/javax.swing.JSlider.setLabelTable(JSlider.java:824)
at becker.robots.x.<init>(SourceFile:32)
at becker.robots.RobotUIComponents.<init>(SourceFile:87)
at becker.robots.RobotUIComponents.<init>(SourceFile:110)
at becker.robots.City.a(SourceFile:228)
at becker.robots.City.<init>(SourceFile:97)
at becker.robots.City.<init>(SourceFile:47)
at Starting_Template.main(Starting_Template.java:10)
This is a bug. See for example https://issues.jboss.org/browse/PLANNER-255?_sscc=t - the becker.jar has nothing to do with it.

Can someone explain the details of this nullPointerException error to me?

So I'm trying to write a Java program using the SAP BO SDK. When I try to create a session, using a predefined class from the SDK, I get a nullPointerException. I copied my code 1 to 1 from an SDK tutorial. Here is my code:
public class Program {
public static void main(String[] args) {
try {
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
...
}
}
}
When I run that code (I commented everything else out for testing), I get the following error:
Exception in thread "main" java.lang.NullPointerException
at com.crystaldecisions.celib.classloader.ClassLoaderHelper$2.getResourceAsStream(ClassLoaderHelper.java:102)
at com.crystaldecisions.celib.classloader.ClassLoaderHelper.getResourceAsStream(ClassLoaderHelper.java:149)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.initializeSystemProperties(SessionMgr.java:258)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.<init>(SessionMgr.java:253)
at com.crystaldecisions.sdk.framework.internal.CEFactory.makeSessionMgr(CEFactory.java:94)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody0(CrystalEnterprise.java:121)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody1$advice(CrystalEnterprise.java:512)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr(CrystalEnterprise.java:1)
at myprogram.main(Program.java:18) <-- Line 4 in my code example above
Does this mean that there is an error in the libraries provided by the SDK? Or that I somehow imported those incorrectly? Is it possible to get any more information from this error code?
Thank you for any help or guidance you can provide.
EDIT: The tutorial used: http://bukhantsov.org/2011/08/getting-started-with-businessobjects-java-sdk/
The issue was that I was referencing JAR files directly from my Program Files. Copying the files to a local folder in my workspace, and referencing them from there fixed the problem.

java cant find or load my program when I have a package heading

I can run programs which do not have a package without any hitch. If I try and add a package then java simply cannot find them. I have set the class path and I have tried running - java packagename.ProgramName.
I have found a number of similar threads on here and have spent four hours going through all of them and trying everything and nothing works for me.
Yet as soon as I edit the .java file and recompile without a package heading - it immediately works perfectly. Why? And how can I fix it? I would like to be able to have my classes organised in packages!
This is the code I am using (I normally use eclipse and just wrote this to try out cmd out of curiosity).
package hello;
public class HelloWorldApp{
public static void helloWorld(){
System.out.println("Hello world");
}
}
and
package hello;
public class HelloBackApp{
public static void helloBack(){
System.out.println("Hello back");
}
public static void main(String[] args){
HelloWorldApp.helloWorld();
helloBack();
}
}
As I say if I delete both the package heading java HelloBackApp runs just fine.
And my path to my program is
c:\Users\sam\javastuff\hello
I have of course tried java hello.HelloBackApp from both the javastuff dir and the hello dir. No joy
It works immediately if I delete both the package headings and type java HelloBackApp from the hello directory.
try as follows,
create folder structure as your package and place java file in that folder
For ex, my java file is under
c:\code\com\test\Test.java and package is "package com.test".
I compiled and run code from
c:\code>
c:\code> javac com\test\Test.java
c:\code> java com.test.Test
Ok after much research I realised what my problem was and have fully resolved it. I think I see why I have been unable to find an "answer" to this question in forums. It is not a simple quick fix - my whole understanding of how to correctly get the class path set up and get a proper compile done was very poor. It becomes a whole new subject if you switch from compiling/running on an IDE to doing so from the command line. I think it is an excellent thing for new programmers to do though as I believe the improved understanding of CLASSPATH is going to be something that will stand us all in good stead for the future.
I found all the answers to my questions here : http://www.ibm.com/developerworks/java/library/j-classpath-windows/
and recommend anyone having similar problems I was having to read through this excellent document. Best wishes to all the other guys struggling with this out there! :)

Error: Could not find or load main class hello.world.HelloWorld

I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error:
run:
Error: Could not find or load main class hello.world.HelloWorld
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
But when I run file HelloWorld.java, it does it fine
I am doing this on Netbeans IDE 7.2
Rather than the coding error, it could be related to IDE. Since the "Run File" runs okay, but 'Run Project" does not, I believe you have something to set up in IDE itself. Right click the project, and select "Set is as Main", now run the project. I am just giving it a guess, may not help you. But it worth a shot.If it does not help, please paste your code too.
Your class needs a public static void main(String[] args) function. And moreover I suspect that the error could be in the package.
If you want your class in <main_package>.<sub_package>, The directory structure is
- main_package
- sub_package
-HelloWorld.java
And be sure to write your class like this.
package main_package.sub_package;
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello " + args[o]);
}
}
This is all due to the naming convention in Java
You need to run the .class file containing the public static void main(String[] args) method..
Here, your HelloWorld.java file might contain a class with main() method.. So, you can run it..
This is because, execution of any Java program starts with the invocation of main().. JVM needs an entry point to your code.. Which is main().. If it doesn't find one.. It will not run..
So, make sure, whatever class file you are running, it should have main() method..
UPDATE :- And for the starting point, may be you can skip using packages.. Just go with plain Java class without packages..
This message can also appear in Eclipse (Juno 4.2.2 in my case) and I have found two potential causes for it.
In my cases:
1. a DTD was in error. I deleted the file and that solved the issue*.
2. having cleaned the project, an external Jar that I had built externally had been deleted as could be seen from Properties -> Java Build Path -> Libraries.*
*Having solved either of the above issues, it was necessary to restart Eclipse
if you are using intellij idea then just rebuilding (clean and build) project might solve your problem . because intellij might be still trying to load the old classes which are not there or changed
Make sure you call looks like below:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("hello user");
}
}
To run a Java class in stand alone mode, public static void main(String[] args) is the entry method, which is must.

Categories

Resources