Даже если у вас установлена Java и/или мультяшник, установленная установщиками окон, вам все равно необходимо set your environment variables. Убедитесь, что вы связываете свою Java с JDK, а не с JRE, но я предполагаю, что когда вы компилируете свой собственный код, вы всегда должны использовать JDK, поскольку у него есть все необходимые инструменты.При создании make-файла для изменения каталога и запуска муравей в этой новой ошибке каталога «JAVA_HOME не определен правильно»
Оригинальное сообщение:
Все это происходит на Windows. Я называю make. Он проверяет папку «code» из svn в каталог, в котором находится makefile. Внутри «code» находится файл build.xml. Я хочу, чтобы мой make-файл изменился на этот каталог, а затем запустил муравей. Я получаю ошибку в моей командной строке:
C:\Users\Ryan\Desktop\maketest>make
svn co (address removed)
Checked out revision 107.
cd code; ant clean compile jar run
uname: not found
basename: not found
dirname: not found
which: not found
Error: JAVA_HOME is not defined correctly.
We cannot execute java
make: *** [runant] Error 1
Я проверил здесь http://sunsite.ualberta.ca/Documentation/Gnu/make-3.79/html_chapter/make_5.html#SEC46, и кажется, что это должно быть выполнимо в моем Makefile:
runant:
cd code; ant clean compile jar run
как это откроет команду в подоболочка, но в этой подоболочке также будет запущена муравей.
Это все работает отлично, если я вручную перехожу в папку с кодом и запускаю муравей. Я только получаю, что JAVA_HOME не корректно определяет ошибку, когда я пытаюсь сделать все это из одного файла makefile.
Makefile:
commands = checkoutcode checkoutdocs runant
svnCode = https://version-control.adelaide.edu.au/svn/SEPADL15S2UG7/code/
svnDocs = https://version-control.adelaide.edu.au/svn/SEPADL15S2UG7/updateDocs
ifdef version
REVISION = -r$(version)
endif
all: full
full: checkoutcode checkoutdocs runant
# ensure you use a single tab for the commands being run under that name
checkoutcode:
svn co $(svnCode) $(REVISION)
checkoutdocs:
svn co $(svnDocs) $(REVISION)
#change directory into the code folder and compile the code
runant:
cd code; ant clean compile jar run
build.xml:
<project>
<!-- add some property names to be referenced later. first one is lib folder to hold all libraries -->
<property name="lib.dir" value="lib"/>
<!-- images directory used to compile with the images and also add them to the jar -->
<property name="src/images.dir" value="images"/>
<!-- ensure the classpath can see all classes in the lib folder by adding **/*.jar -->
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<!-- "Target" attribute is what we will write as a parameter to ant in the command prompt or terminal -->
<!-- eg. "ant clean" will run the commands inside the target tags, which is just to delete the directory
"build" -->
<target name="clean">
<delete dir="build"/>
<echo message="Cleaned "/>
</target>
<!-- compile command. creates a directory for the classes to be stored in, instead of the root folder
and then compiles everything in the src folder, using the classpath properties we set earlier -->
<target name="compile">
<mkdir dir="build/classes"/>
<javac includeantruntime="false" srcdir="src" destdir="build/classes" classpathref="classpath"/>
<echo message="Compiled "/>
</target>
<!-- jar command. this creates an executable jar file called Robot.jar which can run the program in full.
it uses the images and it uses the lejos libraries and embeds them into the jar -->
<target name="jar">
<jar destfile="Robot.jar" basedir="build/classes">
<fileset dir="src/images" />
<manifest>
<attribute name="Main-Class" value="Main"/>
</manifest>
<!-- this line adds everything in the lib folder to the classes being added to the jar,
ie. the lejos classes ev3 and pc -->
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
</jar>
<echo message="Created JAR "/>
</target>
<!-- run command. runs the program. Running the program in the command prompt or terminal is good
because it allows you to see any exceptions as they happen, rather than hiding them in eclipse -->
<target name="run">
<java jar="Robot.jar" fork="true"/>
<echo message="Run "/>
</target>
</project>
Я должен запустить это на разных машинах без каких-либо дополнительных настроек выполняется, и не будет в состоянии подтвердить расположение Java на этих машинах - единственная гарантия, которую я получу, - это то, что Java установлена и переменные среды работают.
Что терминал распечатывает при вводе: 'echo% JAVA_HOME%' –
ok - я добавил JAVA_HOME в качестве переменной среды пользователя. echoing JAVA_HOME печатает путь к jre1.8.0_51 теперь он работает, но я получаю следующее: uname: не найдено basename: не найдено Ошибка: не удалось найти или загрузить основной класс org.apache.tools.ant.launch. launcher –
ok, также пришлось добавить переменную окружения ANT_HOME. теперь он говорит, что он не может найти tools.jar в файле java home lib. Итак, мой друг говорит, что мне нужен JDK вместо JRE. im, загружая его сейчас, но, конечно, ни один из нас не знает разницы между средой выполнения и комплектом разработки с точки зрения использования ant –