简体   繁体   中英

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 ? it can be found at

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

This was made with an old version of Java (pre 1.5) It uses enum as a variable name. Need to as (javac tells you) give command :

javac -source 1.4 gld/*.java

Note : when passing a path to Java both slashes work in Java

If your getting file not found your probably in the wrong folder.

Download a zip to a place lets say to folder:

D:\\prog\\j\\

Now open command prompt, I assume you have java bin JDK in windows PATH?

So now you have default source download zip

gld_rel131_source.zip

in D:\\prog\\j\\

Give following commands :

D:

cd D:\\prog\\j\\

mkdir traffic2\\src

cd traffic2\\src

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

mkdir ..\\bin

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

cd ..\\bin

java gld.GLDSim

When you run javac gld/*.java , you get this kind of error:

./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 :

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. enum , which used as a variable name in the project, is a keyword since J2SE 5.0. 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:

javac -source 1.4 gld\*.java

EDIT 2 Actually it looks like you were in the wrong directory ( gld/ instead of its parent). Simply cd .. and retry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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