对于想了解无法解析JavaApplet项目中的JSObject的读者,本文将提供新的信息,我们将详细介绍无法解析java.io.objectinputstream,并且为您提供关于Android中的J
对于想了解无法解析Java Applet项目中的JSObject的读者,本文将提供新的信息,我们将详细介绍无法解析java.io.objectinputstream,并且为您提供关于Android中的JSONObject和JSONArray解析json数据、Android中的JSONObject和JSONArray解析json数据_PHP教程、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、Eclipse 中的 Java 项目:无法解析 java.lang.Object 类型。它是从所需的 .class 文件中间接引用的的有价值信息。
本文目录一览:- 无法解析Java Applet项目中的JSObject(无法解析java.io.objectinputstream)
- Android中的JSONObject和JSONArray解析json数据
- Android中的JSONObject和JSONArray解析json数据_PHP教程
- angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
- Eclipse 中的 Java 项目:无法解析 java.lang.Object 类型。它是从所需的 .class 文件中间接引用的
无法解析Java Applet项目中的JSObject(无法解析java.io.objectinputstream)
我试图调用JSObject.getWindow(this)
的init
方法,JApplet
但它无法解析该符号getWindow
。
这个问题特别是发生在通过netbeans创建的javafx应用程序项目中,如果在Java应用程序项目中使用getWindow,则该问题将得到解决。
我还包括了plugin.jar
from路径Java\jdk1.7.0_07\jre\lib
。
这是我在netbeans中创建的javafx应用程序项目。
答案1
小编典典原因是jfxrt.lib也有一个名为JSObject的类。这个JSObject没有定义plugin.jar的getWindow函数。如果更改JAR的依赖关系顺序并使Java将JSObject解析为plugin.jar,则Java可以调用getWindow函数。
以下是这两个类的javadocs的链接。请注意,jfxrt一个没有定义getWindow。
http://docs.oracle.com/javafx/2/api/netscape/javascript/JSObject.html
http://www.oracle.com/webfolder/technetwork/java/plugin2/liveconnect/jsobject-
javadoc/netscape/javascript/JSObject.html
Android中的JSONObject和JSONArray解析json数据
今天介绍一下关于json数据解析,我们使用Android中的JSONObject和JSONArray解析json数据,有android开发的朋友可以参考一下。
String strJson = "{"students":[{"name":"Jack","age":12}, {"name":"Vista","age":23}, {"name":"Kaka","age":22}, {"name":"Hony","age":31}]}";
try {
JSONObject jo = new JSONObject(strJson);
JSONArray jsonArray = (JSONArray) jo.get("students");
for (int i = 0; i
JSONObject o = (JSONObject) jsonArray.get(i);
System.out.println("name:" + o.getString("name") + "," + "age:"
+ o.getInt("age"));
}
} catch (JSONException e) {
e.printStackTrace();
}
2.使用gson中的JsonReader解析json数据
try {
String string = "{"class":1, "students":[{"name":"jack", "age":21},{"name":"kaka", "age":21},{"name":"lucy", "age":21}]}";
StringReader sr = new StringReader(string);
JsonReader jr = new JsonReader(sr);
jr.beginObject();
if (jr.nextName().contains("class")) {
System.out.println("班级: " + jr.nextString());
if (jr.nextName().equals("students")) {
jr.beginArray();
while (jr.hasNext()) {
jr.beginObject();
if (jr.nextName().equals("name"))
System.out.print("姓名:" + jr.nextString());
if (jr.nextName().equals("age")) {
System.out.println(" , 年龄:" + jr.nextInt());
}
jr.endObject();
}
jr.endArray();
}
}
jr.endObject();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Json解析库gson: http://code.google.com/p/google-gson/
Android中的JSONObject和JSONArray解析json数据_PHP教程
今天介绍一下关于json数据解析,我们使用Android中的JSONObject和JSONArray解析json数据,有android开发的朋友可以参考一下。
String strJson = "{"students":[{"name":"Jack","age":12}, {"name":"Vista","age":23}, {"name":"Kaka","age":22}, {"name":"Hony","age":31}]}";
try {
JSONObject jo = new JSONObject(strJson);
JSONArray jsonArray = (JSONArray) jo.get("students");
for (int i = 0; i
JSONObject o = (JSONObject) jsonArray.get(i);
System.out.println("name:" + o.getString("name") + "," + "age:"
+ o.getInt("age"));
}
} catch (JSONException e) {
e.printStackTrace();
}
2.使用gson中的JsonReader解析json数据
try {
String string = "{"class":1, "students":[{"name":"jack", "age":21},{"name":"kaka", "age":21},{"name":"lucy", "age":21}]}";
StringReader sr = new StringReader(string);
JsonReader jr = new JsonReader(sr);
jr.beginObject();
if (jr.nextName().contains("class")) {
System.out.println("班级: " + jr.nextString());
if (jr.nextName().equals("students")) {
jr.beginArray();
while (jr.hasNext()) {
jr.beginObject();
if (jr.nextName().equals("name"))
System.out.print("姓名:" + jr.nextString());
if (jr.nextName().equals("age")) {
System.out.println(" , 年龄:" + jr.nextInt());
}
jr.endObject();
}
jr.endArray();
}
}
jr.endObject();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Json解析库gson: http://code.google.com/p/google-gson/
angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
Can’t resolve all parameters for AuthenticationService: ([object Object],?,[object Object])
我已经检查了几乎每个主题,并尝试了多种方法来解决它,但仍然无法在第二天击败它.
我试图像这样在appService中注入第一个authService但是得到了同样的错误
@Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService
我检查了所有DI和服务内部的导入顺序,在我看来一切都是正确的
如果有人可以帮我处理它,我很感激.
Angular 4.0.0
AuthService
import { Injectable } from '@angular/core'; import {Http,Headers,Response} from '@angular/http'; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; import {AppServices} from "../../app.services"; import {Router} from "@angular/router"; @Injectable() export class AuthenticationService { public token: any; constructor( private http: Http,private appService: AppServices,private router: Router ) { this.token = localStorage.getItem('token'); } login(username: string,password: string): Observable<boolean> { let headers = new Headers(); let body = null; headers.append("Authorization",("Basic " + btoa(username + ':' + password))); return this.http.post(this.appService.api + '/login',body,{headers: headers}) .map((response: Response) => { let token = response.json() && response.json().token; if (token) { this.token = token; localStorage.setItem('Conform_token',token); return true; } else { return false; } }); } logout(): void { this.token = null; localStorage.removeItem('Conform_token'); this.router.navigate(['/login']); } }
应用服务
import {Injectable} from '@angular/core'; import {Headers,Http,RequestOptions} from '@angular/http'; import {Router} from "@angular/router"; import {AuthenticationService} from "./auth/auth.service"; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; @Injectable() export class AppServices { api = '//endpoint/'; public options: any; constructor( private http: Http,private router: Router,public authService: AuthenticationService // doesn't work // @Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService // doesn't work either ) { let head = new Headers({ 'Authorization': 'Bearer ' + this.authService.token,"Content-Type": "application/json; charset=utf8" }); this.options = new RequestOptions({headers: head}); } // ==================== // data services // ==================== getData(): Promise<any> { return this.http .get(this.api + "/data",this.options) .toPromise() .then(response => response.json() as Array<Object>) .catch((err)=>{this.handleError(err);}) }
应用模块
import { browserModule } from '@angular/platform-browser'; import { browserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import {BaseRequestOptions,HttpModule} from '@angular/http'; import { MaterialModule} from '@angular/material'; import {FlexLayoutModule} from "@angular/flex-layout"; import 'hammerjs'; import { routing,appRoutingProviders } from './app.routing'; import { AppServices } from './app.services'; import {AuthGuard} from "./auth/auth.guard"; import {AuthenticationService} from "./auth/auth.service"; import {AppComponent} from './app.component'; import {AuthComponent} from './auth/auth.component'; import {NotFoundComponent} from './404/not-found.component'; import { HomeComponent } from './home/home.component'; @NgModule({ declarations: [ AppComponent,AuthComponent,NotFoundComponent,HomeComponent ],imports: [ browserModule,browserAnimationsModule,FormsModule,HttpModule,routing,MaterialModule,FlexLayoutModule ],providers: [AppServices,AuthGuard,AuthenticationService],bootstrap: [AppComponent] }) export class AppModule { }
解决方法
你可以使用
export class AuthenticationService { public token: any; appService: AppServices; constructor( private http: Http,// private appService: AppServices,injector:Injector; private router: Router ) { setTimeout(() => this.appService = injector.get(AppServices)); this.token = localStorage.getItem('token'); }
另见DI with cyclic dependency with custom HTTP and ConfigService
要避免使用setTimeout,您还可以从AppService的构造函数中设置AuthenticationService.appService(或者相反)
Eclipse 中的 Java 项目:无法解析 java.lang.Object 类型。它是从所需的 .class 文件中间接引用的
在 Eclipse 中导入项目后出现以下错误:
java.lang.Object 类型无法解析。它是从所需的 .class 文件中间接引用的
但是,我通过 Window » Preferences » Java » Installed JREs* 在 Eclipse
Kepler中将路径设置为 C:\Program Files\Java\jdk1.6.0_41 。 *
答案1
小编典典这是一个恼人的 Eclipse 错误,它似乎时不时地咬人。有关可能的解决方案,请参阅http://dev-
answers.blogspot.de/2009/06/eclipse-build-errors-
javalangobject.html,否则请尝试以下操作;
关闭项目并重新打开它。
清理项目(它将重建构建路径,因此重新配置 JDK 库)
或者
- 删除并重新导入项目,如有必要,请再次执行上述步骤。
更好的解决方法是尝试 NetBeans 而不是 Eclipse :-)
今天关于无法解析Java Applet项目中的JSObject和无法解析java.io.objectinputstream的讲解已经结束,谢谢您的阅读,如果想了解更多关于Android中的JSONObject和JSONArray解析json数据、Android中的JSONObject和JSONArray解析json数据_PHP教程、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、Eclipse 中的 Java 项目:无法解析 java.lang.Object 类型。它是从所需的 .class 文件中间接引用的的相关知识,请在本站搜索。
本文标签: