• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

java database help

 
Greenhorn
Posts: 4
  • 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
 
author & internet detective
Posts: 39957
804
Eclipse IDE VI Editor Java
  • 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
Posts: 39957
804
Eclipse IDE VI Editor Java
  • 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
  • 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
Posts: 39957
804
Eclipse IDE VI Editor Java
  • 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
  • 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
 
Greenhorn
Posts: 18
  • 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.
 
Ranch Hand
Posts: 75
  • 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
  • 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?


 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic