my dog learned polymorphism*
The moose likes Beginning Java and the fly likes java database help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java database help" Watch "java database help" New topic
Author

java database help

Kyle Anderson
Greenhorn

Joined: Jul 21, 2009
Posts: 4
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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

Joined: Jul 21, 2009
Posts: 4
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

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

Joined: Jul 21, 2009
Posts: 4
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

Joined: Nov 14, 2008
Posts: 18
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

Joined: Mar 30, 2009
Posts: 75
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

Joined: Jul 21, 2009
Posts: 4
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
 
subject: java database help
 
Similar Threads
while running junit it is throwing java.lang.Unsupported Class Version Error
Please Help
connecting to an MS SQL server
Web service deploying problem
A Quest for all of those who don't use RI for HF EJB