Eleonora Ciceri
Eleonora Ciceri

Reputation: 1798

Compile complex Java program in Ubuntu terminal

I have exported my Eclipse Java project in Ubuntu, with all the .java and .class files in place.

The project is composed as follows:

- src
   - package1
        - file1.java
        ...
        - fileN.java
   ...
   - packageM
        - fileM.java
        ...
        - fileN.java

To run the program, I use the following command:

java -Djava.library.path="/path/to/opencv/lib" -cp lib/*:src package.to.main.class.MainClass 

Now, I have changed just a line in a class (which is not the MainClass), and I would like to recompile and run everything. However, when trying with javac in the following way:

javac path/to/main/class/MainClass.java

I obtain millions of errors since:

Some examples:

src/it/polimi/tweetcrawlingpipeline/pipeline/TweetCrawlingPipeline.java:7:    error: package org.opencv.core does not exist
import org.opencv.core.Core;
                  ^
  symbol:   class SVMSample
  location: class TweetCrawlingPipeline
  src/it/polimi/tweetcrawlingpipeline/pipeline/TweetCrawlingPipeline.java:158: error: cannot find symbol
   public GenericClassifier<SVMSample> getTextClassifier() {
               ^

How can I fix these problems?

Thanks.

Upvotes: 2

Views: 576

Answers (1)

gilleain
gilleain

Reputation: 641

This might not be the answer you want, but it rapidly gets to be painful to compile at the command line with just javac. Unless you put your command and classpath into a shell script, it can get fiddly.

If at all possible, I would recommend using something like ant, gradle, or even maven. Well maven can be overkill, but ant is a reasonable start.

Upvotes: 3

Related Questions