小编Con*_*sen的帖子

PyInstaller警告:找不到lib

我知道以前曾在这里问过这种类型的问题,但是我没有找到可行的解决方案。我有一个要在Windows 10上转换为exe的python文件。我运行pyinstaller --onefile --noconsole myfile.py,它输出了很多警告:

C:\Users\conne\Desktop\Python >pyinstaller --onefile --noconsole normal.py
277 INFO: PyInstaller: 3.3.1
277 INFO: Python: 3.6.2
278 INFO: Platform: Windows-10-10.0.15063-SP0
279 INFO: wrote C:\Users\conne\Desktop\Python\normal.spec
280 INFO: UPX is not available.
283 INFO: Extending PYTHONPATH with paths
['C:\\Users\\conne\\Desktop\\python',
 'C:\\Users\\conne\\Desktop\\python']
283 INFO: checking Analysis
284 INFO: Building Analysis because out00-Analysis.toc is non existent
284 INFO: Initializing module dependency graph...
286 INFO: Initializing module graph hooks...
289 INFO: Analyzing base_library.zip ...
5055 INFO: running Analysis out00-Analysis.toc
5058 …
Run Code Online (Sandbox Code Playgroud)

python pyinstaller

10
推荐指数
4
解决办法
2万
查看次数

Can't change the keystore format

I'm trying to make some keystores using keytool from the latest JRE (version 1.8.0_151). When I create the keystore using this command keytool -genkey -alias serverprivate -keystore server.private -keyalg rsa -storepass apassword -keypass apassword it shows me this warning:

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate 
to  PKCS12 which is an industry standard format using "keytool 
-importkeystore -srckeystore server.private -destkeystore server.private
-deststoretype pkcs12".
Run Code Online (Sandbox Code Playgroud)

So I type the command, and it says it's done and …

java encryption cryptography keystore keytool

5
推荐指数
1
解决办法
2万
查看次数

Java - 创建自定义事件和侦听器

我正在尝试用 Java 制作自定义事件和侦听器。我已经看过这些文章和问题:

在 Java 中创建自定义事件

Java 自定义事件处理程序和侦听器

https://www.javaworld.com/article/2077333/core-java/mr-happy-object-teaches-custom-events.html

但我仍然无法真正理解它。这就是我想要做的:

我有一个String对象,其内容随着程序运行而变化。我希望能够向字符串添加一个侦听器,该侦听器侦听它是否包含特定字符串以及何时运行一段代码。我想像这样使用它:

String string = "";
//String.addListener() and textListener need to be created
string.addListener(new textListener("hello world") {
    @Override
    public void onMatch(
         System.out.println("Hello world detected");
    )
}

//do a bunch of stuff

string = "The text Hello World is used by programmers a lot"; //the string contains "Hello World", so the listener will now print out "Hello world detected"
Run Code Online (Sandbox Code Playgroud)

我知道可能有更简单的方法来做到这一点,但我想知道如何做到这一点。

谢谢@Marcos Vasconcelos 指出您不能向String对象添加方法,那么有没有办法使用@Ben 指出的自定义类?

java events listener

3
推荐指数
1
解决办法
7513
查看次数

Java-程序结束时自动停止线程

看一下这段代码:

public class ThreadTest {

    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true) {
                    //some code here
                }
            }
        }).start();

        System.out.println("End of main");
    }

}
Run Code Online (Sandbox Code Playgroud)

通常,main到达的结尾时,程序会终止。但是在此示例中,程序将打印“ main of End”,然后继续运行,因为线程仍在运行。有没有一种方法可以使线程在结束时自动停止,而无需使用类似的东西while(isRunning)

java multithreading

3
推荐指数
1
解决办法
984
查看次数