![]() Java HelloThis involves in 2 steps: compile the. Return pile(grammarStream, IntegerGrammar.ROOT) Ī JavaWorld article has a discussion of classpath resources.Perhaps you’re very familiar with the traditional way of compiling and running Java program in command line as follows: Then use this code in IntegerExpressionParser.java: InputStream grammarStream = ("IntegerExpression.g") Here’s an example from the inclass code for the Parsers class.įirst, put the grammar file IntegerExpression.g in the same folder as the Java class IntegerExpressionParser.java that needs to read it. You may find that your program can no longer find its ParserLib grammar file, because it is trying to read it as a file relative to the project folder, and you are no longer running the program from your project folder.Ī better way would read the grammar as a classpath resource, which allows the code to be packed up in a jar, along with the grammar file, and still be able to find the grammar. This will ensure that your generated JAR file includes the code from the other jar files you depend on, like parserlib.jar and physics.jar in this project.Īfter you finish the dialog, open your command prompt and cd to the folder containing the jar file you just generated.Īssuming its name is myproject.jar, you should now be able to start your program using: Put it somewhere you can find it easily to run it, like your desktop or home folder.ĭon’t put it in your git repo, because it isn’t source code.įor Library Handling, keep the default, “Extract required libraries into generated JAR.” Launch Configuration identifies which program should be exported.įind the one that runs the class containing your main() method.Įxport Destination is the name and location of the JAR file you want to generate. In Eclipse, select File → Export, then Java → Runnable JAR File. Eclipse can also export your program as a “runnable JAR file” that contains all the code in a single file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |