简体   繁体   English

编译NanoVM Java虚拟机

[英]Compiling NanoVM Java Virtual Machine

I have problem with compiling NanoVM project from: 我从以下位置编译NanoVM项目时遇到问题:

http://www.harbaum.org/till/nanovm/index.shtml http://www.harbaum.org/till/nanovm/index.shtml

NanoVM is Java implementation for AVR microcontrollers. NanoVM是AVR微控制器的Java实现。 I know this is not efficient. 我知道这没有效率。 I have problem with "makefile" file. 我的“ makefile”文件有问题。 This makefile contains instructions to compile Java .class from source .java files. 该makefile包含从源.java文件编译Java .class的指令。 But i don't know, how can i run makefile? 但是我不知道如何运行makefile? I was using previously javac.exe compiler to write java standard applications. 我以前使用javac.exe编译器来编写Java标准应用程序。 In install instructions writes that I must have Java SDK (J2SE). 在安装说明中写道,我必须具有Java SDK(J2SE)。 Is there any difference between SDK and JDK? SDK和JDK之间有什么区别吗? I have JDK installed, i have read earlier that there isn't any difference between SDK and JDK, but i'm not sure. 我已经安装了JDK,我之前已经读过SDK和JDK之间没有任何区别,但是我不确定。 I know makefile files are used to manage compilation, i previously used makefile to compile programs wrote in C, but is there some Java compiler like gcc? 我知道makefile文件用于管理编译,我以前使用过makefile来编译用C语言编写的程序,但是是否有像gcc这样的Java编译器? Sorry for my stupid question, i'm quite newbie in makefiles, i think solution is very simple. 对不起我的愚蠢问题,我在makefile中是个新手,我认为解决方案非常简单。 My makefile: 我的makefile:

#
# Makefile for NanoVMTool
#

APP = NanoVMTool
VERSION = 1.5

all: ../$(APP).jar

CLASSPATH = ../../java/examples
NATIVEPATH = ../../java/native

JAVAFILES = AccessFlags.java CodeInfo.java ConstPoolEntry.java FieldInfo.java \
            MethodInfo.java AttributeInfo.java CodeTranslator.java \
        ConstPoolEntryError.java InnerClassInfo.java NanoVMTool.java \
        ClassFileReader.java CommonInfo.java ConvertException.java \
        LineNumberInfo.java NativeMapper.java ClassInfo.java \
        Config.java Debug.java LocalVariableInfo.java UVMWriter.java \
        ClassLoader.java ConstPool.java ExceptionInfo.java \
        MethodIdTable.java Uploader.java NVMComm2.java

# compile target code
$(CLASSPATH)/%.class: $(CLASSPATH)/%.java
    javac -classpath $(CLASSPATH):$(NATIVEPATH) $<

%.class: %.java
    echo "public class Version {" > Version.java
    echo "  public static String version = \"V$(VERSION)\";" >> Version.java
    echo "}" >> Version.java
    javac $<

../$(APP).jar: $(APP).class
    jar cmf $(APP).mf ../$(APP).jar *.class

# convert and upload a class file (should be moved to vm/target Makefile)
asuro-%: $(CLASSPATH)/%.class $(APP).class
    java $(APP) ../config/Asuro.config $(CLASSPATH) $*

mega8-%: $(CLASSPATH)/%.class $(APP).class
    java  $(APP) ../config/Mega8.config $(CLASSPATH) $*

clean:
    rm -f *.class *~

In order to run a Makefile (on Linux / UNIX), you first need to install "make" and any of the other tools that it uses. 为了运行Makefile(在Linux / UNIX上),首先需要安装“ make”及其使用的任何其他工具。 In this case, the tools are just the java , javac and jar commands. 在这种情况下,工具只是javajavacjar命令。 For the last two, you need a JDK installation. 对于最后两个,您需要安装JDK。

But i don't know, how can i run makefile? 但是我不知道如何运行makefile?

Change directory to the directory containing the Makefile, then run 'make' with the appropriate target. 将目录更改为包含Makefile的目录,然后使用适当的目标运行“ make”。 In this case make all . 在这种情况下, make all

Is there any difference between SDK and JDK? SDK和JDK之间有什么区别吗?

There is no such thing as the Java SDK. 没有Java SDK这样的东西。

... but is there some Java compiler like gcc? ...但是是否有像gcc这样的Java编译器?

The Java compiler is javac . Java编译器是javac That is what your makefile is using. 那就是你的makefile正在使用的。


Sorry for my stupid question, i'm quite newbie in makefiles, i think solution is very simple. 对不起我的愚蠢问题,我在makefile中是个新手,我认为解决方案非常简单。

The REAL solution is to find and read a tutorial on Makefiles and how to read, write and use them. REAL解决方案是查找和阅读有关Makefile的教程,以及如何阅读,编写和使用它们。 (In general, the solution to asking newbie questions is to educate yourself so that you aren't a newbie!) (通常,问新手问题的解决方案是教育自己,以确保自己不是新手!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM