小编shu*_*511的帖子

无法在intellij中运行java 11示例程序

public class First {
  public static void main(String[] args) {
    System.out.println("Hello Java 11");
  }
}
Run Code Online (Sandbox Code Playgroud)

我试图用intellij在Java 11中运行上面的程序.但低于错误.

Information:javac 11 was used to compile java sources
Information:Internal caches are corrupted or have outdated format, forcing project rebuild: Module 'eleven-lab' production: java.net.MalformedURLException: unknown protocol: jrt
Information:25/09/18, 6:58 PM - Compilation completed with 1 error and 0 warnings in 4s 516ms
Error:Internal error: (java.net.MalformedURLException) unknown protocol: jrt
java.net.MalformedURLException: unknown protocol: jrt
    at java.net.URL.<init>(URL.java:421)
    at java.net.URL.<init>(URL.java:310)
    at java.net.URL.<init>(URL.java:333)
    at com.intellij.compiler.instrumentation.InstrumentationClassFinder.createJDKPlatformUrl(InstrumentationClassFinder.java:61)
    at org.jetbrains.jps.incremental.instrumentation.ClassProcessingBuilder.createInstrumentationClassFinder(ClassProcessingBuilder.java:125)
    at org.jetbrains.jps.incremental.instrumentation.ClassProcessingBuilder.build(ClassProcessingBuilder.java:93) …
Run Code Online (Sandbox Code Playgroud)

java intellij-idea java-11

14
推荐指数
2
解决办法
8121
查看次数

从java调用包含'const'的javascript?

我正在尝试使用在 js 中开发并在 GitHub 中可用的转译工具。此转译器能够将 javascript 代码转换为 java。

我想通过java代码调用该工具,以便我可以在java中读取js文件并使用在js中开发的transpiler处理它们。该工具使用“const”作为其代码的一部分。在使用 ScriptEngine 时,它​​给了我一个例外。请帮忙!!

示例代码:

public static void main(String[] args) {

    ScriptEngineManager manager = null;
    ScriptEngine engine = null;
    File folder = null;

    try {

        manager = new ScriptEngineManager();
        engine = manager.getEngineByName("nashorn");
        String testConst1 = (String) "const pi = 3.14;";
        String testPrint1 = (String) "function hello(name) {print ('Hello, ' + name +' = '+ pi);}";
        engine.eval(testConst1);
        engine.eval(testPrint1);

        Invocable inv = (Invocable) engine;
        inv.invokeFunction("hello", "pi");
        // System.out.println(); //This one works.

    } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

javascript java transpiler nashorn

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

在 Java 8 中用于连接的“+”运算符被 new StringBuilder() 取代

在 Java 8 中,我编写了一些示例代码。

String s1 = "Hello";  
String s2 = "world";  
String s3 = s1 + s2;  
Run Code Online (Sandbox Code Playgroud)

反编译 .class 文件后,我发现了第三条语句

 String s3 = s1 + s2;  
Run Code Online (Sandbox Code Playgroud)

取而代之

 String s3 = new StringBuilder(s1).append(s2).toString();
Run Code Online (Sandbox Code Playgroud)

这是否意味着不再需要使用显式 StringBuilder 进行优化而只需使用“+”运算符而不是?

java string optimization stringbuilder

4
推荐指数
1
解决办法
3938
查看次数

MySQL 中意外的 NOT EQUAL TO NULL 比较

我在 MySQL 中有下表。

city_data
+------+-----------+-------------+
|  id  | city_code | city_name   |
+------+-----------+-------------+
| 4830 | BHR       | Bharatpur   |
| 4831 | KEP       | Nepalgunj   |
| 4833 | OHS       | Sohar       |
| 4834 | NULL      | Shirdi      |
+------+-----------+-------------+
Run Code Online (Sandbox Code Playgroud)

和下面的查询。

从 city_data 中选择 id、city_code、city_name,其中 city_code != 'BHR';

我本来期待 3 排。

| 4831 | KEP       | Nepalgunj   |
| 4833 | OHS       | Sohar       |
| 4834 | NULL      | Shirdi      |
+------+-----------+-------------+
Run Code Online (Sandbox Code Playgroud)

但只得到 2 行。

| 4831 …
Run Code Online (Sandbox Code Playgroud)

mysql

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