3

I have a project running perfectly in netbeans, windows 8, I build the jar file project-> build with dependencies. When I try to run it from command prompt with this command:

java -jar OracleBackup.jar 

it throws this error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/mycompany/datalayer/DB  
at com.mycompany.oraclebackup.App.main<App.java:12>  
caused by: java.lang.classNotFoundException: com.mycompany.datalayer.DB  
at java.net.URLClassLoader$1.run<unknown source>  

I have searched a lot, I have made some changes, but it still doesn't work.

more details:

path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0_17\bin

When I open the .jar file:

1) I can see DB.class in com/mycompany/datalayer/DB

2)Manifest file exists and this is the content: Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: Moises David Build-Jdk: 1.7.0_17 Main-Class: com.mycompany.oraclebackup.App

Should I mention my .jar dependencies in here too?

Can someone tell me what the problem is and how I can solve it?

Thank you so much!!!

Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
user149855
  • 111
  • 2
  • 2
  • 10
  • how are you exported as a jar ? Are you using Eclipse or is it Maven project? – Makky Jul 16 '13 at 15:48
  • I'am using netbean 7.3.1 and maven. sorry didnt understand "how are you exported as a jar ?". If u mean how I get the jar file.. by project->build with dependencies. created in the target folder. – user149855 Jul 16 '13 at 15:59
  • If you are using maven then you don't need to export like that.You should run Maven plugin to export as runnable jar. It will also include all the dependent jar files. – Makky Jul 16 '13 at 16:49
  • 1
    http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven This should help you – Makky Jul 16 '13 at 16:49
  • Makky, thank you so much!! I finally get it to work! :) – user149855 Jul 16 '13 at 23:29

0 Answers0