READING THE SHARED MEMORY WITH JAVA - AN EXAMPLE WITH VDASH
To start with, you're going to need a few things. I'm not going to assume anything, so lets start at the top. Here are the things you'll need:
- Java
- Eclipse
- Eclipse CDT
- MinGW-W64
- VDash server repository
Installing Java
- Download the Java installer from HERE. If you have a 64-bit OS, download the x64 version, as you're going to be building x86 and x64 DLLs later.
- Run the installer, accept defaults (apart from if it asks to install adware.. I cant remember if it does)
- Verify it works by opening a command window and running:
If it works, you should see something like:Code:java -version
If you don't, you need to add the path to your java installation to your environment variables.Code:C:\Users\Alex>java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)- Hurray, you have Java installed!
Even if you already have Java installed, I recommend keeping it up to date, and making sure you don't have millions of versions installed.
Installing Eclipse
Eclipse is a development environment that does a lot for you, but not everything. It is the tool used to build the VDash server, and up until recently, the VDash apps (which have no made the transition to Android Studio)
- Download Eclipse from their website. Its just an archive, so extract it somewhere memorable.
- Run it. It will ask you to pick a workspace location. Make a new folder. Put it somewhere memorable.
- Yay, Eclipse is installed! You can now go crazy with Java.
Installing Eclipse CDT
CDT are the tools that allow the Eclipse Java environment to use C/C++ build tools, which are needed to create JNI DLLs to access the shared memory.
- In Eclipse, go to 'Help > Install New Software'. Click 'Add' in the top right. Use 'Eclipse CDT' as the name, and 'http://download.eclipse.org/tools/cdt/releases/8.7' as the address, then click OK. Only the bare minimum CDT installation is required, so tick the top box and click next a few times. Accept a license, install it, and restart Eclipse
- Wooooo CDT installed!
Almost there...
Installing MinGW-W64
MinGW-W64 is the toolchain that will build and link the x86 and x64 DLLs for us.
- Download the online installer. Save it somewhere, you wont need it again
- Run it, click next, and let it download the repository information. Once it has, it will show a list of options
- Pick from the options:
- x86_x64 as architecture
- 'sjlj' as the Exception
- Leave the others as default
- Click next, and pick somewhere for it to install. It wants to go in the Program Files folder, but I chose to move it to the root, with the full path being:
Code:C:\mingw-w64\x86_64-5.1.0-posix-seh-rt_v4-rev0- Dont bother with start menu shortcuts...
- Click next, let it download and unpack
- Done!
Not long now...
Clone VDash-server repository
- Using your favourite Git client (TortoiseGIT FTW), clone the VDash-server repository. Its available at: 'https://Flynny75@bitbucket.org/Flynny75/vdash-server.git'. Clone the repository into your Eclipse Workspace folder.
- Open Eclipse, click 'File > Import > General > Existing projects into workspace'. Then browse to your Eclipse workspace folder, and click ok. Select all the projects. Make sure 'Copy projects into workspace' is NOT ticked.
One last thing...
Configuring Eclipse to use MinGW-W64
Eclipse comes with its own compiler, but we are going to use MinGW. So to do that, we need to tell Eclipse the right 'make' command, and where the MinGW installation is.
- In Eclipse, right-click on the server project and click 'C/C++ Build' on the left. Enter a custom build command of 'mingw32-make'
- Beneath that, select 'Environment Variables'. Edit the value for 'MINGW_HOME' to point to the directory of the MinGW installation. Mine is:
Code:C:\mingw-w64\x86_64-5.1.0-posix-sjlj-rt_v4-rev0\mingw64- Edit the PATH variable to include the MINGW_PATH variable like so:
Code:${MINGW_HOME}\bin;${Path}
Building
Using the green play button at the top of the Eclipse window, run the project. It will fail to run (it will complain about being unable to find libraries, but that's ok). Once its build, the .class should be available for the makefile. So now you should be able to right-click on the makefile in the JNI folder, and click 'Make Targets > Build'. This will display a list of make targets. Build 'all'. This should build all the required DLLs for accessing shared memory for a bunch of different games.
Then there's just the matter of explaining how it works...