简体   繁体   English

编译模拟器的问题(java)

[英]Problems with compiling a simulator(java)

I know it might be not the best place for this question but,am doing a master thesis on Smart Traffic controllers , I found this simulator which is written in java, it has been used in many papers I've read , but for some reason I can't/it wouldn't be compiled , anyone can tell me why ? 我知道这可能不是解决这个问题的最佳地点,但是,在做有关智能交通控制器的硕士论文时,我发现了这个模拟器是用Java编写的,已经在我读过的许多论文中使用过,但是由于某种原因我无法/不会被编译,任何人都可以告诉我为什么? it can be found at 可以在下面找到

http://sourceforge.net/projects/stoplicht/ http://sourceforge.net/projects/stoplicht/

This was made with an old version of Java (pre 1.5) It uses enum as a variable name. 这是使用Java的旧版本(1.5版之前)制作的。它使用enum作为变量名。 Need to as (javac tells you) give command : 需要作为(javac告诉您)给命令:

javac -source 1.4 gld/*.java javac -source 1.4 gld / *。java

Note : when passing a path to Java both slashes work in Java 注意:在传递路径到Java时,两个斜杠在Java中均有效

If your getting file not found your probably in the wrong folder. 如果找不到文件,则可能是在错误的文件夹中。

Download a zip to a place lets say to folder: 将zip下载到一个地方,让我们对文件夹说:

D:\\prog\\j\\ d:\\ PROG \\ J□\\

Now open command prompt, I assume you have java bin JDK in windows PATH? 现在打开命令提示符,我假设您在Windows PATH中有Java bin JDK?

So now you have default source download zip 所以现在您有了默认的源下载zip

gld_rel131_source.zip gld_rel131_source.zip

in D:\\prog\\j\\ 在D:\\ prog \\ j \\

Give following commands : 输入以下命令:

D: d:

cd D:\\prog\\j\\ 光盘D:\\ prog \\ j \\

mkdir traffic2\\src mkdir traffic2 \\ src

cd traffic2\\src cd traffic2 \\ src

jar xf D:\\prog\\j\\gld_rel131_source.zip jar xf D:\\ prog \\ j \\ gld_rel131_source.zip

mkdir ..\\bin mkdir .. \\ bin

javac -d ../bin -source 1.4 gld/*.java javac -d ../bin -source 1.4 gld / *。java

cd ..\\bin cd .. \\ bin

java gld.GLDSim java gld.GLDSim

When you run javac gld/*.java , you get this kind of error: 当您运行javac gld/*.java ,会出现这种错误:

./gld/algo/tlc/SL2TLC.java:272: as of release 5, 'enum' is a keyword, and may not be used as an identifier
(use -source 1.4 or lower to use 'enum' as an identifier)
            Enumeration enum = count.elements();

As specified in the error message, add -source 1.4 : 如错误消息中所指定,添加-source 1.4

javac -source 1.4 gld/*.java

And everything will be OK :) 一切都会好的:)

You encounter this error because this project is old (2005), was written for J2SE 1.4 or former versions. 您会遇到此错误,因为该项目是旧版本(2005),是为J2SE 1.4或以前的版本编写的。 enum , which used as a variable name in the project, is a keyword since J2SE 5.0. 从J2SE 5.0开始, enum (在项目中用作变量名)是一个关键字。 Thus, it cannot compile using newer versions, since its usage is reserved. 因此,由于使用保留,因此无法使用较新的版本进行编译。

EDIT 编辑

Since your system is Windows, I would use a backslash ( \\ ) instead of a slash ( / ) for the path argument: 由于您的系统是Windows,因此我会在path参数中使用反斜杠( \\ )而不是斜杠( / ):

javac -source 1.4 gld\*.java

EDIT 2 Actually it looks like you were in the wrong directory ( gld/ instead of its parent). 编辑2 实际上,您似乎位于错误的目录中( gld/而不是其父目录)。 Simply cd .. and retry. 只需cd ..然后重试。

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

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