I know this probably looks like a duplicate. It's not. I've searched for an hour, trying everything I've seen and nothing has worked.
I have an antlr4 grammar file called MathLang.g4. I have put it into its own folder called Grammartest. antlr-4.7.1-complete.jar is in C:\Program Files\Java\libs, along with antlr4.bat and grun.bat. The folder is in the PATH and the jar is in the CLASSPATH. The bat files read as such:
// antlr4.bat
java org.antlr.v4.Tool %*
// grun.bat
java org.antlr.v4.gui.TestRig %*
I then run the following commands in the Grammartest folder:
antlr4 MathLang.g4
javac MathLang*.java
grun MathLang def
antlr4 and javac run silently, generating the .java and then .class files. grun responds with Can't load MathLang as lexer or parser.
How can I fix this?
Apparently I had to add the folder that I was testing in (Grammartest) to the CLASSPATH.
Related
I have a complex build I'm trying to sort out on a new build server. Using CMake for creating the makefiles. Old version of CMake on a different server was 2.8.5. New version is 2.8.12.2. For some reason, the autogenerated CMakeDirectoryInformation.cmake files are missing the CMAKE_C_INCLUDE_PATH and CMAKE_CXX_INCLUDE_PATH, which specify the absolute location of the include headers available to that particular directory. Without that information, the source code in that directory that references headers via a local path (such as foo.h versus ../../../asdf/foo.h) won't compile. Any ideas why these are missing? As far as I can tell this is supposed to be autogenerated by CMake.
I found a useful command that got me further into my build:
SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
But that didn't actually solve my problem. The real issue was that in one of my CMakeLists.txt files I had:
include_directories(
$[XXXX_INCLUDE_DIR}
)
The '[' bracket was causing the build to fail because that include directory was not being used. However, on the old build server, it had no issue with this square bracket.
I'm using an (admittedly aged) version of Scons (2.0.1; upgrading possible but might be difficult), and I'm having trouble with the "Jar" builder. Specifically, it isn't available, and I don't know why. The "JavaClassFile" builder is available and works correctly, but it can't build my jar, failing with this error:
scons: Reading SConscript files ...
AttributeError: 'SConsEnvironment' object has no attribute 'Jar':
File "/home/fred/comms/SConstruct", line 183:
envWithJava.Jar(target='util/myproject.jar', source=['util/myproject.class', 'util/jasypt.jar', 'util/bcprov-ext-jdk15on-152.jar', 'util/Manifest.txt'])
The relevant SConstruct excerpt:
env.Jar(target='util/myproject.jar', source=['util/myproject.class', 'util/jasypt.jar', 'util/bcprov-ext-jdk15on-152.jar', 'util/Manifest.txt'])
"BUILDERS:" from env.Dump() does not list "Jar", but has numerous others, and builds C, C++, Flex and other sources fine.
I'm mainly looking for a way to debug what's happening inside of Scons to make it skip the builder. The jar command is in the same dir as javac, and that builder works, so it doesn't seem path related. The Python files that have the Jar references are present in the lib used by Scons.
Any ideas?
My guess is that you either have no "jar" executable installed (can you call it on the command line?), or it's located in a path that hasn't been properly propagated to your Environment. See also #1 of the "most asked FAQs" at http://scons.org/wiki/FrequentlyAskedQuestions and the very java-specific bug report at http://scons.tigris.org/issues/show_bug.cgi?id=2730 .
Please, provide simplest way to convert .groovy-script to executable file .exe for windows-platform or .jar, for using on multiply platforms.
Thanks
Jar
This project is a simple card game, written in Groovy. It is uses a Gradle script to build a zip file that can be executed like so:
unzip warO.zip
java -jar warO.jar
See this segment of the build.gradle file to see how the manifest is specified for the jar (i.e. the classpath, main class entry point, etc):
jar.archiveName 'warO.jar'
jar.manifest {
attributes 'Main-Class' : 'net.codetojoy.waro.Main'
attributes 'Class-Path' : 'jars/groovy-all-1.6.4.jar jars/guava-collections-r03.jar jars/guava-base-r03.jar'
}
Exe
For an exe, consider a tool such as JWrapper.
I have a .jar file that reads two files from within its current folder and produces as output a .txt file and a separate folder with multiple other .txt files. This works perfectly in Windows using this code to create the directory:
static String dir = System.getProperty("user.dir");
I used the instructions here: https://askubuntu.com/questions/192914/how-run-a-jar-file-with-a-double-click to set up my .jar file to run on a simple double-click, but as of right now, it does nothing when double-clicked. My guess is that the above line of code does not translate well to Linux. Anybody know how to resolve this?
First, try running it on the command-line, with
java -jar <file.jar>
The user.dir property is cross-platform (see here) so it should not be the problem. However, are you using correct file separators? Remember it's '/' on UNIX and '\' on Windows.
Try java -jar Jarname.jar and pass other files as arguments after this command
The code line you gave works fine on linux.
My best guess is that you're then trying to use this directory path by adding a windows-specific path separator (like path + "\subdir") which isn't appropriate for linux (you should build a new File object instead).
Either that, or your jar file isn't being executed at all. Have you tried doing something very simple in your jar file to see if anything is being run? Have you tried running your jar with java -jar myapp.jar to see if any exceptions are thrown or error messages displayed?
You will need to manually tweak your build process to get the jar file marked as executable. In your build xml file, there is a target, "-post-jar", that is called after the jar is built. You'll need to make that target and use Ant's chmod task to modify your jar. Once you do that it will occur every time you make a jar file in that project.
It will run fine as long as you have a JRE installed.
Read this article to know more.
HI All
I am using MS C++ compiler cl.exe at command line to build my projects. The list of directory that must be included with /I is huge. I don't want to include this big huge list for each file I need to compile.
Do you know a way to set the list of folders to be included by default so that these will not appear at the command line when building .cpp files? Does exist some environment variable for that or some configuration?
Thanks
EO
Put the commands in a response file:
"A response file can contain any commands that you would specify on the command line."