File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java database help

 
Kyle Anderson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright guys...got some questions. I don't have a TON of experience with java, but i'm trying to make some standalone database applications. I have the application made and it runs perfectly through NetBeans, although I want to run it outside of the IDE.

I downloaded and installed (i think correctly....) Derby, but nothing. When i double-click the .jar file, nothing happens.

When i run java <App>.jar from the command line I keep getting -

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users>java CarsApp.jar
Exception in thread "main" java.lang.NoClassDefFoundError: CarsApp/jar
Caused by: java.lang.ClassNotFoundException: CarsApp.jar
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: CarsApp.jar. Program will exit.


i tried setting up the paths last night and I thought it worked, although my guess it didn't. I don't have a whole lot of experience to figure out whats going on here. Looked through a bunch of online documentation and couldn't really figure out what the deal is. Any help is appreciated. Thanks guys!

Kyle
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
While you are trying to build a database application, this question is more about "java in general". Moving to that forum. It's easy to find - there will still be a link here in JDBC.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now on to your question. Is this a "self executing jar"? (If you don't know what that is, the answer is no.) If not, what is your main class called?
 
Kyle Anderson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah not sure about the self-executing .jar, but i would no.

'main' is called in CarsApp.java which calls CarsApp.class, which handles most of the execution of the program.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok then. Have you tried:
java -cp CarsApp.jar CarsApp

This states the name of the class (package before it if you have one) in the jar to run.
 
Kyle Anderson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesn't matter where I type that in any directory or any way I keep getting the same error messages in the OP
 
Narendira Sarma
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To execute a JAR from command line you have to use

java -jar <JarName>.jar

Since you use Netbeans, your JAR will have Main-Class property set in the Manifest file. And the libraries (if you use any) would have also been set in the Manifest file. You don't have to use -cp option.
 
Sona Patel
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kyle...

i dont know durby but java CarsApp.jar seems to be wrong method of running any java application. Make sure all java files are compiled and you have .class files in CarsApp.jar

Then as mentioned by Jeanne try running like this java -cp CarsApp.jar CarsApp
Make sure you provide full path of the jar file after -cp.

Regards...
 
Kyle Anderson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for the help guys. It looks like Narendira Saramaa hit it on the head though. The program started to run, now I get errors about Derby...sooo I probably didn't set up the paths correctly. Now, my screen looks like this (quite a mess). It appears that the database server isn't connected and causing it to fault?


 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic