Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Latest commit

 

History

History
95 lines (68 loc) · 5.23 KB

HOW_TO_JAVA.md

File metadata and controls

95 lines (68 loc) · 5.23 KB

JAVA / MAVEN

Instruction on how you can compile/create a runnable jar of the Java program and edit the Java Program over the command line and a Java IDE.


Setup

You need to have installed (or something similar to this):

  • Eclipse IDE for Java Developers (64bit, version 4.7.0 'Oxygen')
    • Eclipse Marketplace plugins:
    • not-needed: Eclipse custom settings (Window > Prefrences):
      • Java > Editor > Save Actions: Activated to format all lines of the source code on save and organize all imports plus additional actions. Use the Formatter Eclipse [built-in].
      • JavaFx: insert in the Scene Builder executable path the path of the Gluon SceneBuilder.exe on your computer (Search for it - right click open file location two times and then copy the path - you need obviously to install it before you can do this step).
      • not-needed: General > Apperance > Colors and Fonts: Set Java Editor Text Font with Edit to Fira Code with Regular and the size of 14.
  • not-needed: Scene Builder (64bit, version 8.3.0, from Gluon) (not the one from Oracle because they gave up developing it?)

How to open the project

  • First clone it via GitHub Desktop (click clone in the web browser on the GitHub page of this project - GitHub Desktop automatically opens) or just use the command line
  • Start Eclipse and click in the menu bar:
    • File > Import
    • search for Existing Maven Projects
    • click next after you selected it
    • then browse to the cloned folder and click OK
    • select the project and click Finish
    • now you are able to edit/open/compile the project
  • Tipp: If you wanna edit the GUI with the SceneBuilder make a right click on any .fxml file and click Open with SceneBuilder

How to export the project

Within Eclipse

To generate a working runnable JAR file (xxx.jar) of this Maven project I needed to do follow the instructions of Jason C and ItamarG3 on stackoverflow

Try creating a new launch configuration from scratch:

  1. Run -> Run Configurations...
  2. Right click "Java Application" in the list on the left and select New
  3. On the right enter a descriptive name.
  4. In the Main tab browse for your project and search for and select the appropriate main class.
  5. Close the dialog.

If you now click in the menu bar of eclipse File select in the new menu Export and then search and select Runnable JAR file. After that select your just now entered descriptive name next to the label Launch configuration:, select Package required libaries into generated JAR and click Finish.

Like c0der I had the problem that my just entered descriptive name didn't showed up under Launch configuration:. But a simple restart of the Eclipse IDE fixed this for me.

Command line

You can also export the project over the command line thanks to Maven.

To do this you need to have installed Maven:

  • Download the Binary zip archieve from https://maven.apache.org/download.cgi
  • Extract the .zip file to a directory of your computer
  • Now open the extracted folder apache-maven-x.x.x (3.5.0 at this time)
  • Open the folder bin
  • Copy the file path of this folder
  • Search (on Windows) for environment variables and click enter
  • Click the button at the bottom right named Environment Variables ...
  • Click below the bottom table the button Edit after you have selected the row that starts with Path
  • Click in the new window the button New
  • Enter in the new row your copied path to the bin folder
  • Click OK (3 times)
  • Open a console and enter mvn -v to test if maven can be used (reload the console if it was opened or restart your computer)

Now you can compile the whole Java project by using the command mvn clean install in the folder DesktopClient or run the shell script build_project.sh which also correctly renames the exported jar file. (Python 3 is therefore needed).

To change how and what get's exported you need to edit the maven pom.xml file.


⚠️

IF you get a notification like probably you run a JRE -> Compile error you have no Java JDK installed or even an old one or you have not activated it:

  1. Download and Install it from here if you haven't already:
  2. After that open the environment variables if you are on Windows
    • Select below the bottom table the button New undefinedEnter the variable name JAVA_HOME undefinedThen click the button Browse Directory... undefinedBrowse to the directory of the installed jdk folder undefined(This was the place on my hard drive: C:\Program Files\Java\jdk1.8.0_144) undefinedClick OK (3 times) undefinedRun the script again (after a restart of all terminals and eventually of the whole computer).