我正在编写一个使用RMI进行通信的Java客户端 - 服务器应用程序.我的问题是,由于某种原因,RMI服务器自行关闭,没有异常或错误.我正在使用Netbeans,我运行了一个配置文件来查看线程.

您可以在附加图像中看到应用程序应该完成执行的时间点作为GC守护程序和RMI Reaper线程的结束.但是,即使应用程序结束,RMI TCP Accept-1099线程仍在运行.令我困惑的部分是,在弹出信息消息后(你可以在屏幕截图中看到它)告诉我服务器已停止,线程继续在图中更新,所以我试图再次连接客户端.虽然它失败了,但我可以看到正在创建一个新的RMI线程(连接18).
我不知道如何调试此问题,我无法弄清楚当RMI接受线程仍在运行时应用程序如何退出.
更新:这是服务器的主要方法:
/**
* Main entry point.
*
* @param args the application arguments - unused.
*/
public static void main(String[] args) {
try {
System.setProperty("java.rmi.dgc.leaseValue", "30000");
sServerProperties = new ServerProperties();
System.setProperty("java.rmi.server.hostname", sServerProperties.
getRmiServer());
createRmiRegistry();
ConfigCore configCore = new ConfigCore();
ServerCore server = new ServerCore(configCore);
LoginHandler loginHandler = new LoginHandler(server);
sRegistry.
bind(Login.class.getSimpleName(), loginHandler.getRemote());
Logger.log(Level.INFO, "Server ready!");
} catch (RemoteException ex) {
Logger.log(Level.SEVERE, "Unable to start RMI registry", ex);
} catch (SQLException ex) { …Run Code Online (Sandbox Code Playgroud) 我遇到了与同一问题有关的两个问题:
我有一个共享对象保存在`pwd`/lib中,而使用它的可执行文件成功编译(通过使用-l和-L开关),在运行时,它给了我悲伤.如果我尝试运行LD_LIBRARY_PATH=/my/absolute/path/to/library/directory ./test它工作正常.但是如果我将LD_LIBRARY_PATH =/my/absolute/path /导出到/ library /目录并执行./test它说它找不到共享库.但是,如果我再做LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./test一次它工作正常!! 关于我做错了什么的任何想法?
第二个问题与LD_LIBRARY_PATH env变量的导出有关.如果我打开终端并键入export LD_LIBRARY_PATH=/path/to/stuff然后键入echo $LD_LIBRARY_PATH,则变量是正确的.但是,如果我编写一个包含export命令的脚本,只需运行它就不会更新变量,而是需要运行source install.sh才能实际保存变量.什么是最好的解决方案?
感谢您的时间!
正如标题所示,我正在尝试使用自定义量化表来压缩 JPEG 格式的图像。我的问题是无法打开生成的文件,错误是:
Quantization table 0x00 was not defined
Run Code Online (Sandbox Code Playgroud)
这就是我的代码的样子:
JPEGImageWriteParam params = new JPEGImageWriteParam(null);
if (mQMatrix != null) {
JPEGHuffmanTable[] huffmanDcTables = {JPEGHuffmanTable.StdDCLuminance, JPEGHuffmanTable.StdDCChrominance};
JPEGHuffmanTable[] huffmanAcTables = {JPEGHuffmanTable.StdACLuminance, JPEGHuffmanTable.StdACChrominance};
dumpMatrices(mQMatrix);
params.setEncodeTables(mQMatrix, huffmanDcTables, huffmanAcTables);
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Iterator writers = ImageIO.getImageWritersByFormatName("JPEG");
ImageWriter imageWriter = (ImageWriter) writers.next();
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(outputStream);
imageWriter.setOutput(imageOutputStream);
imageWriter.write(null, new IIOImage(mSourceImage, null, null), params);
mCompressedImageSize = outputStream.size();
try (FileOutputStream fileOutputStream = new FileOutputStream(mOutFileName)) {
fileOutputStream.write(outputStream.toByteArray());
}
mCompressedImage = ImageIO.read(new ByteArrayInputStream(outputStream.toByteArray()));
Run Code Online (Sandbox Code Playgroud)
我的猜测是它与元数据有关,但我没有找到解决方案。
谢谢,R。
更新:使用十六进制查看器,我确定量化表(DQT - …
我在使用C++中的新正则表达式库时遇到了一些麻烦.这是一个简单的例子:
#include<regex>
#include<string>
#include<iostream>
using namespace std;
int main(){
string text = "123.456";
string pattern = "[0-9]+\\.[0-9]+";
try{
cout << (regex_match(text, regex(pattern, regex_constants::extended)) ? "Pass\n" : "Fail\n");
}catch(...){
cout << "Fail (bad regex)\n";
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
问题是,无论我使用什么类型的匹配(简单,扩展,grep,egrep,awk等),它总是返回false.如果我使用"regex_constants :: simple"它会引发异常,因为不支持括号中的表达式,但我检查了规范,它应该可以正常使用"regex_constants :: extended".
这是结果:
rhobincu@daneel:~/work$ g++ -std=c++11 test.cpp -o test
rhobincu@daneel:~/work$ ./test
Fail
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么吗?
编辑:这可能也是有用的信息:
rhobincu@daneel:~/work$ g++ --version
g++ (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is …Run Code Online (Sandbox Code Playgroud)