0

I have build Java Application with maven, it build all dependency in Target folder, now I am trying to run that jar file, from Linux its giving error as command- java -jar yourApp.jar argument1

Error- no main manifest attribute, in yourApp.jar

after doing some google I ran command as under-

java -cp yourApp.jar  my.pack.testpack.MyMainClass "argument1"

now its giving error-

Caused by: java.lang.ClassNotFoundException: my.pack.testpack.common.components.logger.LoggerFactory 

I am surprised why this issue is coming, if this issue has to come then it should come at run time when running from eclipse when running from eclipse working fine,also I checked the jar file which I am using having bundled this class file.

Please help

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
Sachin Singh
  • 739
  • 4
  • 12
  • 29

2 Answers2

1

You need to specify all your dependencies in the class path of the java command.

Another option is to specify them in the manifest. Use Use of the MANIFEST.MF file in Java for help.

Community
  • 1
  • 1
Simon Sadetsky
  • 544
  • 2
  • 5
-2

In windows cmd : java -jar(file name) please make sure you specify path of your JDK environment setting

mycomputer, properties environment setting, and make sure you have variable called "path" if there is non, make on and make "value" to be the path of jdk bin folder, i.e. c:/Program Files/java/.../bin

In linux:

java -jar <filename>

java path settings in linux: Login to your account and open .bash_profile file

$ vi ~/.bash_profile

Set JAVA_HOME as follows using syntax export JAVA_HOME=. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:

export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

Set PATH as follows:

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
JBALI
  • 89
  • 6
  • 1
    This is not the users problem. He has not packaged the jar correctly, thus it cannot find the Main class. – molenzwiebel Jan 12 '15 at 10:57
  • 1
    all Paths already set,Please clarify while running also need to specify with command,I would like to request Please don't give generalized answer,explain with some example,I believe I have already explained what I did, Thanks – Sachin Singh Jan 12 '15 at 11:00