user3505775
user3505775

Reputation: 339

Error when try to run my project in cmd

I have a structure code like this :

enter image description here

I want to run my program using mcd using javac, like this : javac ListenerZipFile.java. The result like :

enter image description here

Why i can't run my program?

Upvotes: 0

Views: 142

Answers (3)

Rajesh
Rajesh

Reputation: 2155

There are 2 problems here.

  1. Incorrect directory location for compiling packed classes.
  2. classpath no set correctly.

Consider you have, source_dir = D:\~\~\src, jar_location = D:\~\~\lib and package is com.example then your steps to compile are:

  • cd to $source_dir
  • $source_dir> set classpath=.;jar_location
  • $source_dir> javac com\example\Examples1.java or $source_dir> javac com\example\*.java

As per path shared, command to compile should be :

cd C:\ListenerZipfile\src
javac -cp .;C:\ListenerZipfile\lib\*.jar com\sigma\main\ListenerZipFile.java

Command to run java program with above path:

java -cp .;C:\ListenerZipfile\lib\*.jar com.sigma.main.ListenerZipFile

Upvotes: 1

Skaros Ilias
Skaros Ilias

Reputation: 1068

if you are using eclipse (from the screen shot i think you do) then
right click on your project->Properties->Java Build Path, click on Libraries tab->click on "Add External JARs" button-> pick your jar and click OK to close all windows.
This should solve your problem, if your problem is jar dependencies

Upvotes: 0

12dollar
12dollar

Reputation: 655

you are using a package without telling javac where it is located (jnotify for example).

you'd have to use it like:

javac -classpath "path/to/jnotify-0.94.jar" test.java

Upvotes: 2

Related Questions