小编Bin*_*man的帖子

使用Maven将InstallerListener添加到IzPack安装程序项目

我有一个使用maven设置的工作IzPack安装程序项目,并将我的安装脚本install.xml添加到[ installation] [ listeners]:

<listener classname="(company-name).listener.InstallerListener" stage="install"/>


遗憾的是,该行似乎被忽略,调试器不会在InstallListener类中的设置断点处停止.我已阅读的文档InstallListenerS,但因为我有与Maven集成构建过程中它是没有用的; 这是项目对象模型pom.xml的相关部分:

<properties>
    <izpack-standalone.version>4.3.1</izpack-standalone.version>
</properties>

<dependencies>
    <!-- izpack -->
    <dependency>
        <groupId>org.codehaus.izpack</groupId>
        <artifactId>izpack-standalone-compiler</artifactId>
        <version>${izpack-standalone.version}</version>
        <optional>true</optional>
    </dependency>
</dependencies>

<plugins>    
    <!--  IzPack compiler  -->
    <plugin>
        <groupId>org.codehaus.izpack</groupId>
        <artifactId>izpack-maven-plugin</artifactId>
        <version>${org.codehaus.izpack.izpack-maven-plugin.version}</version>
        <dependencies>
            <dependency>
                <groupId>org.codehaus.izpack</groupId>
                <artifactId>izpack-standalone-compiler</artifactId>
                <version>${izpack-standalone.version}</version>
            </dependency>
        </dependencies>
        <configuration>
            <izpackBasedir>${staging.dir}</izpackBasedir>
            <customPanelDirectory>${staging.dir}</customPanelDirectory>
        </configuration>
        <executions>
            <execution>
                <id>standard-installer</id>
                <phase>package</phase>
                <goals>
                    <goal>izpack</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?


注意:已编译的安装程序确实包含指定的InstallerListener类文件,因此它在运行时可用.

java installer izpack maven

8
推荐指数
1
解决办法
730
查看次数

为什么 Write-Host 在 powershell 作业中运行时不起作用?

抱歉,如果我是一个愚蠢的 powershell 菜鸟,但是作业显然无法写入终端有什么问题吗?我该如何解决这个问题?

# test.ps1
function myjob {
    Write-Host "Hello, World!" # doesn't show
}
Start-Job -Name MyJob -ScriptBlock ${function:myjob}
Wait-Job MyJob
Remove-Job MyJob
Run Code Online (Sandbox Code Playgroud)

powershell jobs write-host

6
推荐指数
1
解决办法
5086
查看次数

列表中的协方差

我们如何正确设计以下模型?我有两个班级图书馆.图书馆2参考了图书馆1.但图书馆1 没有图书馆2的参考.

图书馆1:

public class BaseData
{
   /*Some Properties*/
}

public class BaseGroup
{
   /*Some data*/
   public List<BaseData> DataList;
}
Run Code Online (Sandbox Code Playgroud)

图书馆2:

public class ChildData : BaseData
{
   /*Some more data*/
}

public class ChildGroup
{
   /*Some more data*/
   public List<ChildData> DataList;
}
Run Code Online (Sandbox Code Playgroud)

如何设计这些模型,以便我有一个列表.列表可以在库1中启动,稍后在库2中更新.同样从库2中,我需要将ChildGroup对象传递给库1 BaseGroup作为参数的方法.

.net c#

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

将jint转换为jstring

#include <stdio.h>
#include "Package_MyTester.h"

jstring Java_Package_MyTester_NMethod
 (JNIEnv *env, jobject obj, jint first, jint second) {
  jint result_i = first * second;
  jstring result;
  int x = 0;
  for(x=0;x<5;x++) {
      printf("%d",x);
  }

  return result;      
}
Run Code Online (Sandbox Code Playgroud)

该程序将两个正整数相乘。结果必须在jstring中。有没有办法将jint转换为jstring?

c java java-native-interface type-conversion

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

如果不使用strictfp,代码是否会变得不合规?

我们进行了第一次代码审计,有人告诉我,不使用strictfp浮点运算可能会让我们被标记.软件在Windows机器上编码并部署到Solaris机器以供生产使用.有关它的任何建议是真的吗?

另外,如果不使用'strictfp`可以使浮点算术代码不兼容或不可移植,为什么还要以非严格的方式进行计算呢?

CERT安全编码标准,NUM53-J让我觉得它必须使用strictfp:

需要跨不同JVM和平台的浮点运算的一致结果的程序必须使用strictfp修饰符.

java portability strictfp

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

如何使用 BufferedImage 更改图像上文本的颜色?

使用BufferedImage bgImage我想为图像上的文本设置黑色。

BufferedImage bgImage = createBgImageForText();
bgImage.createGraphics().drawString(player.getPlayerName(), 25, 15);
if ("Y".equalsIgnoreCase(player.getCaptain())) {
    bgImage.createGraphics().setPaint(Color.BLACK);
} else {
    bgImage.createGraphics().setPaint(Color.WHITE);
}

mainImg.getGraphics().drawImage(bgImage, 10, 10, null);
Run Code Online (Sandbox Code Playgroud)

但默认情况下,文本始终为白色。如何改变文字的颜色?

java graphics bufferedimage

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

C#中的幻像通用约束

我经常遇到这个问题:我喜欢为不同的返回类型重载一些具有相同参数的方法,但.NET拒绝对密封类/基元的通用约束.我将这种模式称为phantom generics.

  • 我知道一个丑陋的解决方法:在where语句后面放置每个单独的接口类型.

  • 我的问题:有没有办法在泛型中使用显式类型来说明返回类型并保持方法不同?

    这是我的代码:

    public static class Reinterpret {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static unsafe float Cast<T>(int value) where T : float { //'float' is not a valid constraint. A type used as a constraint must be an interface, a non-sealed class or a type parameter.
            return *((float*)&value); //reinterpret the bytes of 'value' to a float
        }
    
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static unsafe float Cast<T>(uint value) where T : float { //'float' is not a valid constraint. A …
    Run Code Online (Sandbox Code Playgroud)
  • c# generics phantom-types

    -1
    推荐指数
    2
    解决办法
    292
    查看次数