所以我有一个隐藏的进程(java 命令行应用程序),输出和输入被重定向。我可以很容易地读取输出并且可以正常工作,但是当我发送命令时它不起作用。
我认为我已经确定输入没有被重定向,因为:
(A) 当我发送WriteLine(//command here); Flush没有命令被程序确认时
(B) 当我取消隐藏 cmd 窗口 ( StartInfo.CreateNoWindow = false;) 时,即使 StandardInput 被重定向 ( StartInfo.RedirectStandardInput = true;),我也可以输入命令并运行它们(在 cmd 窗口中)
这是代码:
namespace bukkit
{
public partial class Form1 : Form
{
private static StringBuilder _txt = new StringBuilder();
private static bool _scrolled = false;
Process mncrft = new Process();
public Form1()
{
InitializeComponent();
mncrft.StartInfo.WorkingDirectory = Path.GetTempPath();
mncrft.StartInfo.Arguments = "-Xmx512M -Xms512M -jar C:\\mncrft\\mncrft.jar";
mncrft.StartInfo.FileName = "java.exe";
mncrft.StartInfo.UseShellExecute = false;
mncrft.StartInfo.RedirectStandardOutput = true;
mncrft.StartInfo.RedirectStandardError …Run Code Online (Sandbox Code Playgroud) 我有这个需要处理大量数据的java模拟器.它工作正常,但我得到了一个int[100000][100][2]与其他大数组一起的数组.该程序说它的内存不足.(Java.lang.outOfMemoryError)
一切都很好,我只是给它更多的记忆,但它似乎总是在约300M左右耗尽即使我允许它2GB.这一切都来自观看任务经理.
我的系统有什么问题,或者这只是我需要处理的java事情?
@DanielPryden
操作系统:Win 7 32Bit 4GB内存
JVM命令:java -Xmx2048M -Xms2048M模拟器
错误数据:必须从IDE(使用IntelliJ)获取.我不知道如何从cmd做到这一点.我认为这就是你要找的东西.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Simulator.main(Simulator.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Run Code Online (Sandbox Code Playgroud) 我正在尝试将CKEditor 4实现到我正在处理的ASP NET网站中,但我无法弄清楚如何从内联编辑器中保存编辑后的材料我知道如何使用旧版本来完成它,但我只是不喜欢我不明白这个过程.
我已经在论坛上看了......没有v4论坛.
我看着在对文件....找不到它.
我有一种感觉,这是一项简单的任务,但我只是不知道如何.
所以我正在尝试使用asp net mvc 4.5,我在登录razor视图中工作.这个页面与其他页面不同,所以我在顶部
@model HSServer.Models.LoginModel
@{
ViewBag.Title = "Log in";
Layout = null;
}
Run Code Online (Sandbox Code Playgroud)
用Layout = null;这样它不使用母版页.
我尝试运行该应用程序,并在该行上抛出一个InsufficentExecutionStackException Layout = null;并说
Insufficient stack to continue executing the program safely. This can happen from
having too many functions on the call stack or function on the stack using too
much stack space.
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我发生了什么!
编辑
它似乎与Layout = null删除无关,并没有帮助,只是简单地将错误移动了一行.仍在挖掘.
我正在尝试制作一个列表的列表.我这样做:
public static List<string>[] words = new List<string>[30];
public static List<string>[] hints = new List<string>[30];
Run Code Online (Sandbox Code Playgroud)
我称之为:
foreach (string item in vars.directory)
{
reader2 = new StreamReader(item);
while (reader2.Peek() > 0)
{
string line = reader2.ReadLine();
if (line.StartsWith("#"))
{
vars.words[counter].Add(line.Substring(1, line.Length - 1)); //here
}
else if (line.StartsWith("-"))
{
vars.hints[counter].Add(line.Substring(1, line.Length - 1)); //another here
}
else if (line == "@end")
{
counter++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只想补充一点,vars是我保存公共变量的地方,当循环开始时,计数器确实为0.
编辑 在我的匆忙中,我忘了添加问题......哎呀......
这是:当我调用add函数(或任何其他函数)时,它返回一个空引用异常.我怎样才能解决这个问题?
我正在编写一个简单的 java 控制台游戏。我使用扫描仪读取来自控制台的输入。我试图验证我是否要求输入一个整数,如果输入字母,我不会收到错误。我试过这个:
boolean validResponce = false;
int choice = 0;
while (!validResponce)
{
try
{
choice = stdin.nextInt();
validResponce = true;
}
catch (java.util.InputMismatchException ex)
{
System.out.println("I did not understand what you said. Try again: ");
}
}
Run Code Online (Sandbox Code Playgroud)
但它似乎创建了一个无限循环,只是打印出 catch 块。我究竟做错了什么。
是的,我是 Java 新手
我试图在函数中间暂停一段时间(5秒)
这是我尝试过的,但它不起作用
(function MessagesAjax() {
$.post('/api/messages/get', function(data) {
for (var i = 0; i < data.length; i++) {
$.jGrowl(data[i].Body.toString().substring(0, 150), { header: 'New Message', sticky: true, });
markDisplayed(data[i].Id);
}
setTimeout(MessagesAjax, 5000);
});
})();
function markDisplayed(id) {
setTimeout(5000); //want it to pause here
$.post("/api/messages/markdisplayed" + id);
console.log("Marking displayed");
}
Run Code Online (Sandbox Code Playgroud)
我只需要它暂停,以便在将帖子发送回服务器之前有一段延迟
我几乎可以肯定setTimeout不是我想要的,但我不确定还能用什么
我试图将这段c ++代码转换为c#:
if (latch_state & 0x1) {
MC->setPin(AIN2pin, HIGH);
} else {
MC->setPin(AIN2pin, LOW);
}
if (latch_state & 0x2) {
MC->setPin(BIN1pin, HIGH);
} else {
MC->setPin(BIN1pin, LOW);
}
if (latch_state & 0x4) {
MC->setPin(AIN1pin, HIGH);
} else {
MC->setPin(AIN1pin, LOW);
}
if (latch_state & 0x8) {
MC->setPin(BIN2pin, HIGH);
} else {
MC->setPin(BIN2pin, LOW);
}
Run Code Online (Sandbox Code Playgroud)
我知道足以转换MC->setPin(PinNum, state)为MC.setPin(pinNum, state)所以它们不是问题,但我对if语句将成为什么感到困惑.
latch_state是类型uint8_t,但似乎处理像一个字节(这是我试图将其转换为),并且0x1似乎也是一个字节.
那么二元和操作如何在if语句中进行求值?
对于转换,我应该这样做
if ((latch_state & 0x1) == 0x0)或者if ((latch_state & 0x1) …