I'm fairly new to Gradle so I'm trying to build a Java project and not sure about the dependencies. I have never gotten Gradle configured to be able to do my tests or now a jar file to compile and run.
My build.gradle
:
apply plugin: 'java'
apply plugin: 'maven'
repositories {
jcenter()
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.json:json:20160212'
testCompile 'junit:junit:4.12'
}
And this is what I get on the console stating that it doesn't see my import:
error: package org.json.simple does not exist
import org.json.simple.JSONParser;
Here's my class:
import org.json.simple.*;
import java.io.*;
import java.util.*;
import java.lang.*;
public class FileLoader {
@SuppressWarnings("unchecked")
public static void main(String args[]) {
JSONParser parser = new JSONParser();
int count = 0;
try {
Object obj = parser.parse(new FileReader(
"Consumers.json"));
JSONObject jsonObject = (JSONObject) obj;
JSONArray array = jsonObject.getJSONArray("people");
} catch (Exception e) {
e.printStackTrace();
}
}
}