任何人都可以指导如何使用GDB调试器在Linux上调试JNI代码(如果可能请建议其他选项).
-My JNI project when running on Linux is leading to a JVM crash.
-The CPP code has been compiled into .so files.
-I run the project like this : *java xyz.jar -commandline_args_to_project*.
Run Code Online (Sandbox Code Playgroud)
我安装了Gdb,但我没有得到如何使用它来调试项目.我是否还需要使用-g选项t debug .so文件编译.cpp文件?
我在64位Centos机器上安装了64位Java.我的查询是,如果我不指定-d64选项,即使没有安装32位JVM,JVM也会以32位模式运行?
如果我们可以将-d64选项与"javac"一起使用,我也有点好奇.如果是,那么它意味着什么或者它可以在哪里使用?我在阅读这篇文章时遇到过这个问题.
谢谢
我正在尝试一些基本的Java I/O操作,我尝试运行以下代码:
public static void main(String[] args) {
File file = new File("fileWrite2.txt"); // create a File object
try {
FileWriter fr = new FileWriter(file);
PrintWriter pw = new PrintWriter(file); // create a PrintWriter that will send its output to a Writer
BufferedWriter br = new BufferedWriter(fr);
br.write("sdsadasdsa");br.flush();br.append("fffff");br.flush();
pw.println("howdy"); // write the data
pw.println("folks");
pw.flush();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的命令时,我在创建的文件中得到以下输出:
howdy
folks
f
Run Code Online (Sandbox Code Playgroud)
谁能解释为什么'f'会在最后一行?
以下代码引发以下异常:
URL u = new URL("file://D:/abc.xml");
InputStream input = u.openStream();
Run Code Online (Sandbox Code Playgroud)
抛出异常:
Exception in thread "main" java.net.UnknownHostException: D
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.NetworkClient.openServer(NetworkClient.java:118)
at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
at java.net.URL.openStream(URL.java:1010)
at com.nuance.nlu.JavaApiExmaple.main(Exmaple.java:191)
ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
JDWP exit error AGENT_ERROR_NO_JNI_ENV(183): [../../../src/share/back/util.c:820]
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用:
URL u = new URL("file:///D:/abc.xml"); (文件后加3个斜杠),或:URL u = new URL("file:/D:/abc.xml"); (文件后加1个斜杠:)代码行InputStream input = u.openStream(); 执行正常。
我有一个嵌套地图的案例,如下所示:
private final static Map<String, TreeMap<Long,String>> outerConcurrentMap = new ConcurrentHashMap<>();
Run Code Online (Sandbox Code Playgroud)
我知道这ConcurrentHashMap是线程安全的,但我想知道TreeMap这个 CHM 持有的 s ,它们在 CHM 内部也是线程安全的吗?
我正在做的操作是:
get(K)使用.从 CHM 检索 TreeMaptailMap(K,boolean)。clear()CHM。在这种情况下我想要一个线程安全的结构。上述实现是否线程安全?如果没有,请提出解决方案。
该组合\;是分号的转义序列,即;.
请原谅我之前问题的简短,实际上我正在使用这个“\;” 逃避“;” 在 Linux 终端和 Windows 上。它用于分隔 URL 的不同参数查询字符串。仅使用“;” 适用于 Windows,但不适用于 Linux。但是使用“\;” 代替 ”;” 适用于 Linux 和 Windows。URL 被传递给某个命令以处理 URL 指向的资源。
我的查询很简单,是 '\;' ';' 的标准转义字符 在 linux 和 windows 控制台/shell 上?
java ×5
url ×2
concurrency ×1
file-io ×1
gdb ×1
io ×1
jvm ×1
linux ×1
printwriter ×1
treemap ×1