我正在尝试将JNI用于我最近的项目.我的IDE是NetBeans.在创建C/C++项目之后,我试图从项目属性 - > C compiler-> include目录添加JDK目录.我在/ usr/lib/jvm /目录中找不到任何include或include/linux目录.
我应该在哪里寻找"include"或"include/linux"目录?
我整天都在尝试这种不同的变化,但收效甚微.请有人帮忙解释一下我做错了什么?我只是一个关于线程的初学者.
private JTextArea text = new JTextArea();
private JButton button = new JButton("Cancel");
public StatusFrame() {
text.setEditable(false);
this.add(text);
this.add(button, BorderLayout.EAST);
this.setSize(new Dimension(150, 100));
this.setVisible(true);
}
public void updateStatus(String textIn) {
text.setText(textIn);
}
public JButton getButton() {
return button;
}
Run Code Online (Sandbox Code Playgroud)
在另一个课程中,我正在调用可能需要一段时间才能完成的方法.我希望能够调用StatusFrame.updateStatus()方法来让用户了解进度.这就是我所拥有的:
someMethod() {
// prevent GUI from freezing using threads
final Runnable r = new Runnable() {
public void run() {
status = new StatusFrame();
}
};
SwingUtilities.invokeLater(r);
//do something
status.update("process 1 completed");
//do something else
status.updateStatus("Process 2 completed");
}
Run Code Online (Sandbox Code Playgroud)
出现框架,但运行之后的代码似乎都没有运行/处理.它只是停止/阻止/某事.但GUI仍然有效 …
我从数据库获取日期为2013-05-03 00:20:29.0.我想解析EEE MMM dd HH:mm:ss zzz yyyy格式化的日期,但是当我解析它时,我得到了这个异常:
java.text.ParseException: Unparseable date: "2013-05-03 00:20:29.0"
我的代码如下:
String createdDate = "2013-05-03 00:20:29.0";
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date parseDate = format.parse(createdDate);
Run Code Online (Sandbox Code Playgroud) 我有这个代码,但它创建了一个DLL文件:
private void btnCompile_Click(object sender, System.EventArgs e)
{
CSharpCodeProvider csp = new CSharpCodeProvider();
ICodeCompiler cc = csp.CreateCompiler();
CompilerParameters cp = new CompilerParameters();
cp.OutputAssembly = Application.StartupPath + "\\TestClass.dll";
cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("System.dll");
cp.ReferencedAssemblies.Add("System.Data.dll");
cp.ReferencedAssemblies.Add("System.Xml.dll");
cp.ReferencedAssemblies.Add("mscorlib.dll");
cp.ReferencedAssemblies.Add("System.Windows.Forms.dll");
cp.ReferencedAssemblies.Add("CSharpScripter.exe");
cp.WarningLevel = 3;
cp.CompilerOptions = "/target:library /optimize";
cp.GenerateExecutable = false;
cp.GenerateInMemory = false;
System.CodeDom.Compiler.TempFileCollection tfc = new TempFileCollection(Application.StartupPath, false);
CompilerResults cr = new CompilerResults(tfc);
cr = cc.CompileAssemblyFromSource(cp, this.rtfCode.Text);
if (cr.Errors.Count > 0)
{
foreach (CompilerError ce in cr.Errors)
{
Console.WriteLine(ce.ErrorNumber + ": " + ce.ErrorText);
} …Run Code Online (Sandbox Code Playgroud)