yonutix
yonutix

Reputation: 2449

Java set compiling arguments

I'm having a Java project(Not so simple, with several packages and a .jar) which compile just well in Eclipse, but when I'm trying to compile it from command line I get src/Main.java:1: error: package core.simulation does not exist

This is the .classpath file:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
    <classpathentry kind="lib" path="Config.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

Can you explain me how to compile and run the project?(what arguments to give to javac and java). Thank you!

Upvotes: 0

Views: 146

Answers (1)

Ruslan
Ruslan

Reputation: 1096

The javac command should know about all dependencies. Argument list should include all source file as well as reference jars. The following commands can be used for generic case:

# prepare class file output dir
mkdir -p bin

# collect all source files into list or prepare it manually
find src -iname *.java > file_list

# combine classpath by reference jars for example under lib dir
for p in $(ls lib); do cp="$cp:lib/$p"; done
# for p in $(ls lib); do cp="$cp;lib/$p"; done # for windows using ';' path separator

# compile 
javac -d bin -cp "$cp" @file_list

Upvotes: 2

Related Questions