Robin
Robin

Reputation: 89

Compiling Java with multiple classes with javac

Until now I always used an IDE to write my java apps. Now for different reasons, mainly also to understand more about the language and the things the IDE is just making for you, I switched to vim and have now the following problem:

I wrote two classes:

package seedInformatik.LinearList;

import seedInformatik.LinearList.*;

// A linear list. Contains LinearListElement<T>
public class LinearList<T> { 

and

package seedInformatik.LinearList; 

public class ListElement<T> {

Now I want to compile LinearList and get the following:

➜  LinearList javac LinearList.java
LinearList.java:10: error: cannot find symbol
    private ListElement<T> first; // head of list
            ^

Both classes are in the same dir. What do I miss?

Many Thanks Robin

Upvotes: 1

Views: 1792

Answers (1)

Gabriel Mesquita
Gabriel Mesquita

Reputation: 2391

Maybe this can help:

javac *.java // compliles all java files in the dir

java MyClass // runs the particular file

If your files are under some package you need to specify the package like this:

javac com.mypackage/.*java

java com.mypackage.MyClass

I would also recommend using a build tool like maven: http://maven.apache.org/guides/getting-started/index.html#How_do_I_make_my_first_Maven_project

Upvotes: 2

Related Questions