0

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!

2
  • possible duplicate stackoverflow.com/questions/4764768/… Commented May 11, 2016 at 14:28
  • We need to see your directory structure and the .classpath file isn't used by javac. Commented May 11, 2016 at 14:28

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

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.