小编whw*_*ght的帖子

在Mac上作为应用程序启动jar文件(从扩展坞)

我有一个应用程序打包为我的mac上的jar文件.我希望从Dock中启动此应用程序,就像它是.app文件一样.有没有办法做到这一点?

macos jar

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

如何使用 Liberty 更改生成的 JSESSIONID 的长度?

在 Liberty 上运行我的项目时,特别是在 Chrome 中,我收到一些警告消息。

[WARNING ] Detected JSESSIONID with invalid length; expected length of 23, found 28, setting: BD14EBEEDBE53803FAE565131A03 to null.
Run Code Online (Sandbox Code Playgroud)

这是因为 Liberty 正在生成长度为 28 的 JSESSIONID,但 Liberty 配置文件将 httpSession 属性 idLength 默认为 23。如果我设置

<httpSession idLength="28" />
Run Code Online (Sandbox Code Playgroud)

在 Liberty server.xml 中,我没有在日志中收到这些警告消息。但是,我想在不更改 server.xml 的情况下解决这个问题。

是否可以将 JSESSIONID 的生成方式更改为默认长度 23?或者也许这是一个糟糕的方法?

javascript session jsessionid websphere-liberty

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

当试图绘制它时,JPanel会冻结我的整个应用程序

我正在编写Oregon Trail的学校项目,我正在实施狩猎迷你游戏.我们正在使用具有卡片布局的模型视图演示器.当HuntingPanel切换到它调用run,然后JOptionPane出现,但随后整个应用程序冻结,我必须强制退出.我在一个单独的项目中编写了整个狩猎游戏,并且刚刚将文件带到了Oregon Trail游戏中.它在自己的项目中运行良好JFrame.我不知道该怎么做.

我这称之为初始化面板,切换到它,然后运行游戏.

    public void initialize(int ammo) {
         player.setBullets(ammo);
         bulletLabel.setText("Bullets: "+player.getBullets());
         presenter.switchToPanel(OregonTrailPresenter.HUNTING_PANEL);
         run();
     }
Run Code Online (Sandbox Code Playgroud)

这是我的run方法.

public void run() {
    // starting message
    JOptionPane.showMessageDialog(null, "You have reached a nearby field to hunt. You will stay\nhere until " +
            "you run out of ammunition or click Return to Trail.");
    // while the player has bullets or doesn't click return to trail
    while (player.getBullets() > 0 && stillHunting) {
        // creates random animals
        checkForAnimal();
        // moves …
Run Code Online (Sandbox Code Playgroud)

java swing drawing freeze jpanel

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

插入字符串 &lt;&lt; 重载 C++ 时出错

我正在尝试在 C++ 中的类上重载 << 运算符。每当我将普通字符串(例如“”)插入输出流时,我都会收到无法理解的编译错误。我以前做过一次,没有任何问题,所以我很困惑。

friend std::ostream& operator<<(std::ostream& out, Variable v);

std::ostream& operator<<(std::ostream& out, Variable v) {
    out << v.type;
    out << " ";
    out << v.name;
    return out;
}
Run Code Online (Sandbox Code Playgroud)

这是输出:

src/Variable.cpp: In function 'std::ostream& operator<<(std::ostream&, Variable)':
src/Variable.cpp:35:9: error: no match for 'operator<<' in 'out << " "'
src/Variable.cpp:35:9: note: candidates are:
src/Variable.cpp:33:15: note: std::ostream& operator<<(std::ostream&, Variable)
src/Variable.cpp:33:15: note:   no known conversion for argument 2 from 'const char [2]' to 'Variable'
In file included from /usr/local/Cellar/gcc/4.7.0/gcc/lib/gcc/x86_64-apple-darwin10.8.0/4.7.0/../../../../include/c++/4.7.0/string:54:0,
             from src/../inc/Variable.h:4,
             from src/Variable.cpp:1: …
Run Code Online (Sandbox Code Playgroud)

c++

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

如何获取Linux内核中文件的大小?

我找到了这个链接(http://www.spinics.net/lists/newbies/msg41016.html)并且一直在考虑这样做。所以我在内核模块中编写了代码:

\n\n
#include <linux/path.h>\n#include <linux/namei.h>\n#include <linux/fs.h>\n\nstruct path p;\nstruct kstat ks;\nkern_path(filepath, 0, &p);\nvfs_getattr(&p, &ks);\nprintk(KERN_INFO "size: %lld\\n", ks.size);\n
Run Code Online (Sandbox Code Playgroud)\n\n

这不会编译,因为:

\n\n
/root/kernelmodule/hello.c:15: warning: passing argument 1 of \xe2\x80\x98vfs_getattr\xe2\x80\x99 from incompatible pointer type\ninclude/linux/fs.h:2563: note: expected \xe2\x80\x98struct vfsmount *\xe2\x80\x99 but argument is of type \xe2\x80\x98struct path *\xe2\x80\x99\n/root/kernelmodule/hello.c:15: warning: passing argument 2 of \xe2\x80\x98vfs_getattr\xe2\x80\x99 from incompatible pointer type\ninclude/linux/fs.h:2563: note: expected \xe2\x80\x98struct dentry *\xe2\x80\x99 but argument is of type \xe2\x80\x98struct kstat *\xe2\x80\x99\n/root/kernelmodule/hello.c:15: error: too few arguments to function \xe2\x80\x98vfs_getattr\xe2\x80\x99\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以自从我查看这个文档以来我真的很困惑:http://lxr.free-electrons.com/source/fs/stat.c#L40

\n\n

现在我在 …

c linux kernel linux-kernel

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