• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

java app work from IDE but generate runtime error from command line

 
Greenhorn
Posts: 8
Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using Netbeans IDE to complie and run NyARToolkit which uses the java3d,JMF libraries. It is compiled with some warning for the use of deprecated API







I can run the sample application form the IDE but when I made an executable jar or tried to run the code from commandline, I am getting an error.



The same error is thrown in the IDE too when the jmf library was not added as an external library. In the executable jar, the manifest file is having the main class info and the library path info. Since that was not working I tried to invoke the main java class from commandline. I tried to set the class path environment variable to point the jmf library file but still getting error.

Any idea what could have gone wrong?

Thanks,

Mamatha
 
Marshal
Posts: 72672
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both error messages are pretty self-explanatory.
You ought not to use deprecated API. Look up the methods you are using, and it will suggest alternative.
You are attempting to get the first member of a 0-length array. If you look up the Vector API (why are you using Vector at all?) it will give more details.
 
Campbell Ritchie
Marshal
Posts: 72672
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Mamatha Achuthan
Greenhorn
Posts: 8
Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply. After spending hours on the code, finally I could make out that the problem was with the class path. The program was using Java Media Framework and related code which was deprecated. (JMF was not developed since 2002, the generic code based on JMF was deprecated.) When JMF was installed in the system, it has automatically set the classpath environment variable in the MSDOS path format. When I tried to compile the sample code from IDE, I added the JMF jars to JRE /ext/lib -a bad practice, for which I paid the penalty. The JRE has the JMF jars, so it did not throw any compile time errors or missing library error. When I tried to run the program from IDE, it failed, and threw a run time error as in my last post. Then I added the library jars as external jars thus fixing the problem. I successfully run the application.

The same happened when I tried to make the same application an executable jar. Then I tried to run it from the command line and got the same error. setting CLASSPATH environment variable didn't help. I dont know why. Finally when I specified, 'classpath' (absolute path to jars )option with java command , it worked.

 
Campbell Ritchie
Marshal
Posts: 72672
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done sorting it out
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic