Download presentation
Presentation is loading. Please wait.
Published byHarriet Price Modified over 9 years ago
1
Time to apply stuff… Faculty of Mathematics and Physics Charles University in Prague 5 th October 2015 Workshop 1 – Java Wrestling
2
Slides you’ve opened contains: 1. Tools we are going to build Java projects with 2. Directions how to import Eclipse Java project into Eclipse 3. Java project build trouble shooting, concretely: 1.Setting a new JDK into Eclipse to build projects with 2.Configuring projects to use correct JDK 3.Setting build dependencies for a project 4.Setting correct Java code compliance level 4. How to run a Java application
3
We are going to use Java 1.6+ https://java.com/en/download/ https://java.com/en/download/ We are going to use Eclipse 3.7.1+ https://www.eclipse.org/downloads/ https://www.eclipse.org/downloads/
4
Projects are going to be stored at GitHub Every project from GitHub can be downloaded as ZIP MarioAI4J https://github.com/kefik/MarioAI/tree/master
5
Download ZIP file and extract into some directory We will refer to that as $PROJDIR Open Eclipse and import all projects
6
> MENU > Window > Show View > Package Explorer
7
Right-click some empty space within Package Explorer view and choose Import…
8
Choose General > Existing Projects into Workspace and click Next
9
Click on Browse…
10
Choose $PROJDIR directory containing all unzipped projects, click OK
11
Eclipse will list all existing projects within that dir, keep them all ticked and click Finish.
12
All projects should appear within Package Explorer view, they should be auto-compiled (hopefully without errors).
13
There are 3 common problems you may encounter after you import Java projects 1. You are building projects using wrong version of JDK (or some custom Java SDK) 2. Projects have build path messed up 3. Projects are compiled using wrong Java compatibility level We will now address them them all…
14
This problem is resolved in two steps 1. Make sure Eclipse is using correct JDK 2. Make sure that your projects are built using correct JDK
15
Problem 1 – Step 1 In this step we will set Eclipse to use different JDK than the one its currently using We assume you have JDK downloaded and unzipped somewhere
16
> MENU > Window > Preferences
17
MENU > Window > Preferences > Installed JREs Click Add.
18
Choose Standard VM, click Next.
19
Click Directory.
20
Find directory with JDK you want to use, click OK.
21
Eclipse should list many JDK JARs, click Finish.
22
Then “tick” a JDK you want to build your projects with, finish by clicking OK.
23
Problem 1 – Step 2 Now we will check / make sure that the project is truly using JDK we have just set
24
Right-click a project within Package Explorer view that cannot be built and choose Properties.
25
Go to Java Build Path and Libraries tab, locate currently used JRE System Library.
26
If the JDK used is wrong, select it and click on Remove. If correct JDK is used, skip this step (click Cancel).
27
The JDK is removed, now click on Add Library.
28
Select JRE System Library and click Next.
29
Select a Workspace default, if there is a correct JDK in brackets. If not, choose Alternate JRE and select appropriate one. Click Finish.
30
Libraries will now show newly added JRE System Library with correct version. Click OK.
31
And do not forget to ensure your project is rebuild, choose MENU > Project > Clean.
32
Select Clean all projects in order to rebuild any dependencies as well. Click OK.
33
Do this for every project you have imported, to ensure that all projects are built using correct JDK
34
This problem happens if Eclipse does not build “Agents” project against “Framework” E.g. in MarioAI4J, it may happen that project MarioAI4J-Agents is not built with MarioAI4J project on build path We will resolve this by adding missing project to the build path
35
Right-click project within Package Explorer view that cannot be built and choose Properties.
36
Choose Java Build Path and Projects tab. If there are some invalid projects (red-crossed), remove them. Then click Add.
37
Tick MarioAI4J project (or whatever dependency is required) and click OK.
38
Project is now on Build Path, click OK
39
If Eclipse does not rebuild your project automatically, force it. > MENU > Project > Clean
40
Choose Clean all projects and click OK
41
This should fix all compilation problems If not, you probably have “Problem 3” to fix as well…
42
This problem happens if Eclipse is trying to build your project for JDK1.5+ with code compatibility set to JDK1.4- This problem is indicated by errors on lines containing @Override annotation We will resolve this by setting correct Java code compatibility level for a project
43
Right-click project within Package Explorer view that cannot be built and choose Properties.
44
Go to Java Compiler and set Compiler compliance level to 1.8 (if using JDK8, otherwise choose lower level that fits JDK versiou you are using), click OK.
45
Eclipse will require you to rebuild the project, click Yes.
46
Hopefully, this fixes everything
47
To run a Java Project you have to first locate a class with main(String[] args) method Typically a project called xxx-Agents is going to have example agents containing such a method Then, you can right-click such a class in Package Explorer view and run it as Java Application
49
Contact: Jakub Gemrot gemrot@gamedev.cuni.cz gemrot@gamedev.cuni.cz Use subject: AI1 – 2015 – Hxx – Project Build Trouble xx is a number of the workshop your reporting your troubles for (01, 02, …)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.