compilation - compiling a java program with a package containing a file from a different directory -
i have packaged java program in 1 directory wants import class different directory, won't compile. trying compile command in can understand going on, don't want use ide yet. i've tried every permutation of specifying classpath on javac line, compiler refuses find main packaged java program. believe simple task, can't figure out. i've researched internet , books, can find basic compilation instructions , compilation instructions when classes located in same directory. has been 0 help. know how this?
you can compile multiple .java files @ same time, if in different folders.
for example, if files:
project - folder1 - file1.java - folder2 - file2.java
then go project folder , execute following command.
on windows:
javac.exe folder1\file1.java folder2\file2.java
on osx/linux:
javac folder1/file1.java folder2/file2.java
but project becomes larger , starts including more dependencies, should consider using apache ant or gradle, tools make life easier when compile java projects many files, dependencies and/or complex folder structures.
Comments
Post a Comment