本文介绍了Java:构造函数JSONTokener(InputStreamReader)未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java中遇到一个非常奇怪的问题,我仅在某些机器上出现错误,我想知道是否有什么方法可以避免这种情况:

I have a quite strange issue with Java, I'm getting an error on some machines only, I would like to know if there is any way I can avoid that:

这是相关的代码行:

JSONTokener jsonTokener = new JSONTokener(
                new InputStreamReader(is, "UTF-8"));

这是我在某些计算机上遇到的错误

This is the error I get on some machines

The file *.java could not be compiled. Error raised is : The constructor JSONTokener(InputStreamReader) is undefined


推荐答案

在发生此错误的机器上检查类路径。发生这种情况是因为包含 JSONTokener 类的库来自旧版本,其中只有 JSONTokener(String)可用,而不是 JSONTokener(Reader)

Check the classpath on the machines where this error occurs. This could happen because the library that contains the JSONTokener class is from an older version, where only the JSONTokener(String) is available, and not JSONTokener(Reader).

这篇关于Java:构造函数JSONTokener(InputStreamReader)未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 05:55