0

Objective -I want to run an open source java project jar i.e https://github.com/grundid/nfctools-examples/releases which I need for my host card emulation android project.

I'm referring to this example for running the this java jar project

java -cp nfctools-examples.jar org.nfctools.examples.hce.HceDemo

But I'm getting error -Could not find or load main class SDK

I also tried the command with complete path

java -cp C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples.jar C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples\org\nfctools\examples\hce\org.nfctools.examples.hce.HceDemo

I have gone through the following links but did not find a solution

"Error: Could not find or load main class My.class"

Error: Could not find or load main class- Novice

Error: Could not find or load main class

My java version is 1.7.0

I have not worked much with java projects, please help!

EDIT

Path of the nfctools-examples.jar is C:\DATA\setups\ACR1281U-C1 SDK v1.0

enter image description here

Commands used

C:\Users\sony>java -cp nfctools-examples.jar org.nfctools.examples.hce.HceDemo  
Error: Could not find or load main class org.nfctools.examples.hce.HceDemo                                                                                      
C:\Users\sony>cd C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples\org\nfctools   
                                                                                                                                 C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples\org\nfctools>java -cp nfctools-examples.jar org.nfctools.examples.hce.HceDemo                           
Error: Could not find or load main class org.nfctools.examples.hce.HceDemo 

C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples\org\nfctools>java -cp C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples.jar org.nfctools.examples.hce.HceDemo                                                                         
Error: Could not find or load main class SDK 
Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
  • `java -cp nfctools-examples.jar org.nfctools.examples.hce.HceDemo` for this does this jar file exist in CWD? does this class exist in that jar file ? – jmj Jan 07 '15 at 18:24
  • C:\Program Files\Java is java path and the path variable is also set.I tried the command with & without setting the CWD (with cd cmd) to pat where the jar is located – Rachita Nanda Jan 07 '15 at 18:29
  • no I meant where is this jar located related to your current working directory ? – jmj Jan 07 '15 at 18:30
  • My first thought is that there's no manifest in the executable JAR to say what the main class is. – duffymo Jan 07 '15 at 18:35
  • @JigarJoshi pls see my edit , I have mentioned the path of jar and the commands I used – Rachita Nanda Jan 07 '15 at 18:37
  • your screenshot is not friendly, could you copy and paste the content instead ? – jmj Jan 07 '15 at 18:38
  • or `C:\DATA\setups\ACR1281U-C1 SDK v1.0` go to this directory by `cd` and then invoke `java -cp nfctools-examples.jar org.nfctools.examples.hce.HceDemo` – jmj Jan 07 '15 at 18:39
  • @duffymo there is an MAnifest.mf file at path nfctools-examples\META-INF I'll paste the commands aswell .thanks – Rachita Nanda Jan 07 '15 at 18:44
  • @duffymo i don't think there should be a manifest to say which is the main class, as the command contains the main class name. – Yazan Jan 07 '15 at 18:49

1 Answers1

0

i think this should work for you:

java -cp "C:\DATA\setups\ACR1281U-C1 SDK v1.0\nfctools-examples.jar" org.nfctools.examples.hce.HceDemo

first problem was jar not in current directory,

second issue is space in jar path, you should use " when the path have space.

third, you should not append full path before the main class name, just package.name.className

Yazan
  • 6,074
  • 1
  • 19
  • 33