• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Runnable jar file not working correctly

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a project in Eclipse Luna like (File -> New -> Java Project) in Java perspective named as Demo App. Under it I have created a package named demo which contains 2 java files
1. Application (which is the main one)
2. SpeakText (its method is used in Application) this java file is the result of my first post i.e. How to create audio based application

Everything is working fine when I run Application.java according to the time it says Good Night etc. But when I created jar file. By following steps
1. Right click on Demo App then click on Export.
2. Under java I selected Runnable JAR File.
3. In the Launch Configuration, I selected my java file i.e. Application.java and selected particular destination then finish.

When I opening the jar file its working correctly all the methods of Application.java are running except it is not saying anything like Good Morning or Record Saved Successfully.
Can anyone please tell me what is wrong here. In eclipse its working but not in jar file...
 
Greenhorn
Posts: 4
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sanurag,

What command are you using to run the jar file? Do you get any stack traces?
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply Andras. What commands means I am just directly clicking on it..thats it
 
Sheriff
Posts: 26770
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "it" that you are clicking on?
 
Andras Toth
Greenhorn
Posts: 4
Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul: I guess he double clicks the "jar" file?

Sanurag: I suggest that you try to run the jar file from the command line, like this:



In this way, it might print some stack traces, based on which the problem can be identified.
 
Marshal
Posts: 73979
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post screenshots; they are difficult to read. You can copy the contents of the command prompt easily; It is easy enough on a Unix/Linux box because you can highlight the text with your mouse, but you can even do it on Windows, and you can read how to do it here.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I didn't know that Thanks Campbell...But here is the error part


Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/speech/freett
s/VoiceManager
at demo.SpeakText.dospeak(SpeakText.java:13)
at demo.Application.speakNow(Application.java:525)
at demo.Application.main(Application.java:2125)
Caused by: java.lang.ClassNotFoundException: com.sun.speech.freetts.VoiceManager

at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more


 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add all the required jar files to the classpath whenever you run the code. IDEs do that for you, but when running from the command line, or double-clicking the jar file, you need to do that in some other way.
 
Campbell Ritchie
Marshal
Posts: 73979
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the VoiceManager class in the standard Java® API? If not, you should probably use something different. Classes starting with com or sun might be removed in future releases.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please tell me any other available way..
 
Campbell Ritchie
Marshal
Posts: 73979
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know myself, I am afraid.
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using FreeTTS is fine, irrespective of its package name. You just need to add all the required jar files to your classpath
 
Campbell Ritchie
Marshal
Posts: 73979
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. It isn't one of the files they might remove, then.
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They can't, because it was never part of the class libraries to begin with :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic