0

Currently trying to run a java file that requires a jar package, typed the javac command and it was all good, when trying to run

java javafile

i get error that i'm referencing classes not available (because they are in the jar package), so I found out I've to add the jar package as classpath like so

java -cp "..\file.jar": javafile

but only to get an error

Error: could not find or load main class javafile

tried to find solutions for this, but they all say I'm writing the filename or packages or path wrong, it is not in a package, and i already ran it without the classpath, so why it fails to load now?

newRuser
  • 885
  • 1
  • 7
  • 9
  • 1
    You need to add both the jar and the current directory if you are running a class from the current directory. E.g. `-cp ..\file.jar:.`. Note that if the class is called `javafile` then it's bad naming. It should be both meaningful, and start with a capital letter. – RealSkeptic Apr 03 '17 at 11:35
  • The Windows version of Java uses `;` as a path separator. You are trying to use `:` so java is looking in a non-existent file called `..\file.jar:`. – Klitos Kyriacou Apr 03 '17 at 12:40

0 Answers0