我有一个 php 文件,它将 Json 字符串存储在 $result 中。我现在有一个处理它的 java 程序,主函数返回一个字符串数组。作为 java 新手,我不确定在创建运行配置时要传递什么参数。当我尝试导出可运行的 jar(将运行配置参数留空)时,它说在类中找不到主要方法。我觉得这与参数传递有关,但我不知道该怎么做。对不起这个菜鸟问题。这是我的代码:
package jiraBurnDown;
public class JiraCurrentSprintBurnDownDataAttributes {
public long _startTime = 0;
public long _endTime = 0;
public String sprintResponse;
public String _statisticsField = "";
public Map<String, JSONArray> _changes = new HashMap<String, JSONArray>();
public Map<String, IssueState> _changesByIssue = new HashMap<String, IssueState>();
public class IssueState {
public boolean isInSprint = false;
public Double estimatedWork = 0.0;
public IssueState(boolean isInSprint, Double estimatedTime) {
this.isInSprint = isInSprint;
this.estimatedWork = estimatedTime;
}
public String[] main(String sprintResponse) {
String res[]=null;
JSONObject obj = (JSONObject) JSONValue.parse(sprintResponse);
if (obj != null) {
//createEmptySeries();
res=extractAllInfo(obj);
}
else
System.out.println("Not Working ");
return res;
}
}
private String[] extractAllInfo(JSONObject obj) {
String statisticField =extractStatisticsFieldName(obj);
String time=extractStartAndEndTime(obj);
String changes=extractChangesInfo(obj.get("changes"));
String workData=extractAndSaveBaseLine(obj.get("workRateData"));
String scopeChanges=extractAndSaveScopeChange();
String[] info=new String[5];
info[0]=statisticField;
info[1]=time;
info[2]=changes;
info[3]=workData;
info[4]=scopeChanges;
return info;
}
private String extractStatisticsFieldName(JSONObject obj) {
Object rawObj = obj.get("statisticField");
if (rawObj != null && rawObj instanceof JSONObject) {
_statisticsField = ((JSONObject) rawObj).get("name").toString();
//addPoint(DataAttributes.DEFAULT_SERIES_NAME, _statisticsField);
}
return _statisticsField;
}
//and other functions to process the JSON obj
我的 php 文件是
$result=curl_exec($ch);
curl_close($ch);
$result=json_decode($result, true);
$result=json_encode($result);
$out=shell_exec("java -jar /JiraInfo.jar $result");
var_dump($out);