标签: runtime-error

Java Runtime.getRuntime()非法参数异常

我在使.getruntime.exec()正常工作时遇到了一些问题.以下是处理该部分的代码:

while (line != null)
{
  String name = line;
  String commandFull = commandFirst + name + commandLast;

  String[] fullCommand = new String[] {commandFirst, name, commandLast};
  for(int i=0;i<3;i++)
  {
    System.out.print(fullCommand[i]);
  }
  Runtime runner = Runtime.getRuntime();
  Process p = runner.exec(fullCommand);

  outFile.println(fullCommand);

  line = inFile.readLine();
}
Run Code Online (Sandbox Code Playgroud)

它打印出应该看起来的命令.当我在这里运行程序时输出:

adfind -b dc=stuff,dc=com -f "cn=user" |find "displayName" >> fullList.txt
Exception in thread "main" java.lang.IllegalArgumentException
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at lookup.main(lookup.java:41)
Run Code Online (Sandbox Code Playgroud)

java runtime-error

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

C Malloc运行时错误

我有以下代码片段:

typedef struct person {
    char *first ;
    char *last ;
    char *location ;
    struct person *next_person ;
} person ;

person *make_person(char *first, char *last, char *location) {
    person *personp = (person*) malloc(sizeof(struct person));

    personp->first = (char*) malloc(sizeof(strlen(first) + 1));
    personp->last = (char*) malloc(sizeof(strlen(last) + 1));
    personp->location = (char*) malloc(sizeof(strlen(location) + 1));

    strcpy(personp->first, first);
    strcpy(personp->last, last);
    strcpy(personp->location, location);

    personp->next_person = NULL;

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

当我将它与我的其余代码集成时,它开始执行,然后继续弹道.

*** glibc detected *** ./level1: free(): invalid next size (fast): 0x0804a188 ***
Run Code Online (Sandbox Code Playgroud)

知道出了什么问题吗?我觉得它与我的malloc有关.

c malloc runtime-error dynamic-memory-allocation

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

如何修改C++ runtime_error的字符串?

我有一个继承自std::runtime_error这样的类:

#include <string>
#include <stdexcept>

class SomeEx : public std::runtime_error
{
public:
    SomeEx(const std::string& msg) : runtime_error(msg) { }
};
Run Code Online (Sandbox Code Playgroud)

表示msg总是类似"无效的类型ID 43".有没有办法用另一个构造函数(或另一个方法)构建"什么字符串",以便我只提供整数类型ID?就像是:

SomeEx(unsigned int id) {
    // set what string to ("invalid type ID " + id)
}
Run Code Online (Sandbox Code Playgroud)

c++ runtime-error exception std

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

C程序卡住,甚至没有进入主程序

我为FCFS调度编写了以下代码.问题是这段代码编译正常,但执行后./a.out,没有显示任何内容,程序卡住了.它甚至没有"Reading" printf在开头打印声明main().问题是什么?

#include <stdio.h>

struct process
{

  int at;
  int bt;
  int wt;
  int tt;
  int rt;
  char pid[5];

} p[5];

int i, j;
int n = 0;

void main()
{
  printf("Reading");
  FILE *fp;
  fp = fopen("in1.txt", "r");
  char sample;
  if (fp != NULL )
  {
    sample = getc(fp);
    while (sample != EOF);
    {
      if (sample == '\n')
        n++;
      sample = getc(fp);
    }
    fseek(fp, 0, 0);
    for (i = 0; i < n; i++) …
Run Code Online (Sandbox Code Playgroud)

c gcc runtime-error

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

AttributeError:'module'对象没有属性'pack'

import struct

f = open('file.bin', 'wb')
value = 1.23456
data = struct.pack("f", value)
f.write(data)
f.close()

f = open('file.bin', 'rb')
print struct.unpack('f',f.read(4))
f.close()
Run Code Online (Sandbox Code Playgroud)

我尝试执行上面的代码,它给了我错误:

AttributeError:'module'对象没有属性'pack'

我使用的是python 2.7.5,我检查了模块列表,并且"struct"就在那里.

python struct module runtime-error

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

将包含元组的列表转换为字符串

我有一个包含元组的列表.我需要将整个列表转换为字符串进行压缩.这段代码在Python 2.7中运行良好:

tt = '{}'.format(tt)
Run Code Online (Sandbox Code Playgroud)

但是在Python 2.6中我收到以下错误:

  hist = '{}'.format(hist)
ValueError: zero length field name in format
Run Code Online (Sandbox Code Playgroud)

tt看起来像是数据[(2, 3, 4), (34, 5, 7)...]

除了升级Python版本之外,还有什么解决方法吗?

python runtime-error

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

检查平衡分组字符时在线判断运行时错误

这是我的代码,用于检查一组分组字符是否正确平衡.它在我的本地机器上工作正常,但在线判断给我一个运行时错误.

#include <iostream>
#include <string>
#include <stack>
using namespace std;

bool balanced(string exp)
{
    stack<char> st;
    int i;
    for(i=0;i<exp.length();i++)
    {
            if(exp[i]== '{' || exp[i]=='[' || exp[i]== '(') st.push(exp[i]);
            else if(exp[i]=='}'){
                if(st.top() == '{' && !st.empty()) st.pop();
                else return false;
            }
            else if(exp[i]==')'){
                if(st.top() == '(' && !st.empty()) st.pop();
                else return false;
            }
            else if(exp[i]==']'){
                if(st.top()=='['  && !st.empty()) st.pop();
                else return false;
            }
    }
    if(st.empty())return true;
    else return false;
}

int main() {
    string exp;int n;
    cin >> n;
    cin.ignore();
    while(n--) …
Run Code Online (Sandbox Code Playgroud)

c++ stack runtime-error

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

尝试删除工作簿中的所有工作表,然后使用VBA添加其他工作表

尝试删除工作簿中的大多数工作表,然后将其重新添加,我一直遇到错误.

我无法删除工作簿中的所有工作表; 至少需要一张纸.精细.所以我先创建一个名为的表TempSheet.

targetWorkbook = ActiveWorkbook.Name
'/* ...more code... */
Application.Workbooks(targetWorkbook).Activate
Application.Workbooks(targetWorkbook).Worksheets.Add.Name = "TempSheet"
Run Code Online (Sandbox Code Playgroud)

所以现在,我想要删除TempSheet工作簿中的所有工作表.所以我试着这样做:

For Each ws1 In Application.Workbooks(targetWorkbook).Worksheets
    If ws1.Name <> "TempSheet" Then
        Workbooks(targetWorkbook).Sheets(ws1.Name).Delete '/* Line X. */
    End If
Next
Run Code Online (Sandbox Code Playgroud)

当我单步执行代码并进入时Line X,我得到了错误Can't enter break mode at this time.我试着更换所有的代码Line X只ws1.Delete,我得到了同样的信息.我想至少单步执行代码,以便我可以看到正在删除的工作表.

我的代码的另一部分是这样的,我想从另一个工作簿中取出所有工作表,并将它们放在第一个工作簿中,我从上面删除了所有工作表.我的代码如下:

Application.Workbooks("OtherWorkbook").Activate '/* Line Y. */
For Each ws2 In Application.Workbooks(sheetsWorkbook).Worksheets
    ws2.Copy After:=Workbooks(targetWorkbook).Sheets(ws1.Name)
Next
Run Code Online (Sandbox Code Playgroud)

我打开一个断点Line Y,在我收到Can't enter break mode at this time错误后,我按下了 …

macros excel vba runtime-error excel-vba

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

Python龙卷风通过finish()停止执行

我对龙卷风还比较陌生,如果条件通过,我将尝试停止执行方法,否则应继续执行下一行代码(类似于return)

这是我的代码卡住的部分,

class PostMatchHandler(BaseRequestHandler):
    result1 = "some sql query".execute()
    if not result1:
        response.update({'info': 'Levels Completed', 'status': settings.STATUS_200})
        self.write(response)
        self.finish()

    else:
        result1 = result1[0]
        do_something()
    self.write(response)
Run Code Online (Sandbox Code Playgroud)

BaseRequestHandler是:

class BaseRequestHandler(tornado.web.RequestHandler):
    """
    Base Class for all the future classes
    Activities like logging should be done in this class.
    Allow cors request in this class
    """

    def set_default_headers(self):
        print "setting headers!!!"

    def write_error(self, status_code, **kwargs):
        response = {}
        handle_error_messages..
        self.write(response)

    @staticmethod
    def extract_psycopg2_integrity_error(error):
        return error.message.split("Key")[1].replace("(", "").replace(")", "").split(".")[0].replace("=", " ")

    def prepare(self):
        logging.debug(
            "[info] Class …
Run Code Online (Sandbox Code Playgroud)

python runtime-error tornado

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

在Perl 6 REPL中使用chdir的奇怪(内部?)默认构造函数错误消息

我遇到以下错误:

&*chdir('/home/account')   
Run Code Online (Sandbox Code Playgroud)

无法将工作目录更改为"/ home/account":"IO :: Path"的默认构造函数仅接受命名参数

我需要更改什么才能克服此错误?

(我使用的是perl6版本2013.12 Ubuntu 14.04)

io runtime-error internals perl6 chdir

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