0

I have a java file called EXICodec.java which performs various operations thanks to the jar exificient.jar. They are in the same folder.

Here is the structure of the file EXICodec.java :

import java.io.FileInputStream; 
import java.io.FileOutputStream;
[...]
import com.siemens.ct.exi.helpers.DefaultEXIFactory;

public class EXICodec {
    /*
     * Main
     */
    public static void main(String[] args) 
    {
        for (int i=0;i < args.length ; i++) 
        {
            System.out.println(args[i]);    
        }
    }
    /*
     * Attributes
     */
    [...]

    /*
     * Constructor (default)
     */
    public EXICodec()
    {[...]}

    /*
     * Methods using import from exificient.jar
     */
    [...]

When I compile, I run the following command : (and it works)

javac -cp exificient.jar EXICodec.java

And then I want to execute:

java -cp exificient.jar EXICodec

but I have the following error :

Error : java could not find or load main class EXICodec

Am I missing some basic thing ? I thought it was link to the package name. I had one and place the file in the proper folder but I got the same problems : it compiles but does not run.

1
  • Is there a package in which EXICodec resides? You need to supply the fully qualified class name of the main class to run. Commented May 27, 2015 at 12:30

2 Answers 2

1

Add the current directory (that contains the file EXICodec.class) to the classpath:

java -cp exificient.jar;. EXICodec

The current directory is indicated by .

If you are using a Unix-like operating system (Mac OS X or Linux) instead of Windows, use : instead of ; as the path separator:

java -cp exificient.jar:. EXICodec
Sign up to request clarification or add additional context in comments.

Comments

0

You need to add the location of EXICodec.class to the classpath.

Something along the lines of

java -cp "exificient.jar:." EXICodec

(assuming you're on Unix)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.