Eclipse 怎样在java application 模式的项目中运行Job

zzndino 2008-04-08 02:58:06
Eclipse 怎样在java application 模式的项目中运行Job
我在eclipse 中建立一个新的Job
import java.text.SimpleDateFormat;
import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public final class Clock {

public Clock() {
super();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Job job = new Job("Clock Job") {
protected IStatus run(IProgressMonitor monitor) {
System.out.println("Run in Job");
Display display = new Display();

Shell shell = new Shell(display);

shell.setText("Clock in Job");

shell.setSize(200, 100);
SimpleDateFormat bartDateFormat =new SimpleDateFormat("MMMM-dd-yyyy EEEE HH-mm-ss-SSS");
Date date = new Date();
Label lab = new Label(shell,SWT.NONE);
lab.setText(bartDateFormat.format(date));
lab.pack();
shell.pack();
shell.open();
while (!shell.isDisposed())

{
if (!display.readAndDispatch())

display.sleep ();

}

display.dispose ();
lab.dispose();
return Status.OK_STATUS;
}
};
job.schedule(); // start as soon as possible
Display display = new Display();

Shell shell = new Shell(display);

shell.setText("Clock in main");

shell.setSize(200, 100);
SimpleDateFormat bartDateFormat =new SimpleDateFormat("MMMM-dd-yyyy EEEE HH-mm-ss-SSS");
Date date = new Date();
Label lab = new Label(shell,SWT.NONE);
lab.setText(bartDateFormat.format(date));
lab.pack();
shell.pack();
shell.open();
while (!shell.isDisposed())

{
if (!display.readAndDispatch())

display.sleep ();

}

display.dispose ();
lab.dispose();
System.out.println("Run in main");
}

}


编译没问题,但是运行时会
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:214)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:157)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:157)
at Clock.main(Clock.java:24)
Caused by: java.lang.SecurityException: Signers of 'org.eclipse.core.runtime.ListenerList' do not match signers of other classes in package
at java.lang.ClassLoader.checkPackageSigners(ClassLoader.java:281)
at java.lang.ClassLoader.defineClass(ClassLoader.java:215)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:148)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:557)
at java.net.URLClassLoader.access$400(URLClassLoader.java:120)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:962)
at java.security.AccessController.doPrivileged(AccessController.java:275)
at java.net.URLClassLoader.findClass(URLClassLoader.java:488)
at java.lang.ClassLoader.loadClass(ClassLoader.java:607)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at org.eclipse.core.internal.jobs.JobListeners.<init>(JobListeners.java:60)
at org.eclipse.core.internal.jobs.JobManager.<init>(JobManager.java:85)
at org.eclipse.core.internal.jobs.JobManager.getInstance(JobManager.java:149)
at org.eclipse.core.internal.jobs.InternalJob.<clinit>(InternalJob.java:46)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:192)
... 3 more
请问怎么才能在Java application模式中运行Job?
...全文
398 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzndino 2008-04-08
  • 打赏
  • 举报
回复
最后解决的方法就是虽然他是一个plugin但是我还是用Run as Java application,这样虽然解决了问题但是不知道怎么才能让他脱离Eclipse 运行。谢了兄台,先把分给你吧。
霜之哀伤 2008-04-08
  • 打赏
  • 举报
回复




-------
友情提醒楼主早日结贴。
霜之哀伤 2008-04-08
  • 打赏
  • 举报
回复
lz是3.2版本的?

不要用 run as javaapplication
用,run as java bean


3.3版本没这个问题
Agile Java™ Development With Spring, Hibernate and Eclipse is a book about robust technologies and effective methods which help bring simplicity back into the world of enterprise Java development. The three key technologies covered in this book, the Spring Framework, Hibernate and Eclipse, help reduce the complexity of enterprise Java development significantly. Furthermore, these technologies enable plain old Java objects (POJOs) to be deployed in light-weight containers versus heavy-handed remote objects that require heavy EJB containers. This book also extensively covers technologies such as Ant, JUnit, JSP tag libraries and touches upon other areas such as such logging, GUI based debugging, monitoring using JMX, job scheduling, emailing, and more. Also, Extreme Programming (XP), Agile Model Driven Development (AMDD) and refactoring are methods that can expedite the software development projects by reducing the amount of up front requirements and design; hence these methods are embedded throughout the book but with just enough details and examples to not sidetrack the focus of this book. In addition, this book contains well separated, subjective material (opinion sidebars), comic illustrations, tips and tricks, all of which provide real-world and practical perspectives on relevant topics. Last but not least, this book demonstrates the complete lifecycle by building and following a sample application, chapter-by-chapter, starting from conceptualization to production using the technology and processes covered in this book. In summary, by using the technologies and methods covered in this book, the reader will be able to effectively develop enterprise-class Java applications, in an agile manner!



Agile Java™ Development With Spring, Hibernate and Eclipse is a book about robust technologies and effective methods which help bring simplicity back into the world of enterprise Java development. The three key technologies covered in this book, the Spring Framework, Hibernate and Eclipse, help reduce the complexity of enterprise Java development significantly. Furthermore, these technologies enable plain old Java objects (POJOs) to be deployed in light-weight containers versus heavy-handed remote objects that require heavy EJB containers. This book also extensively covers technologies such as Ant, JUnit, JSP tag libraries and touches upon other areas such as such logging, GUI based debugging, monitoring using JMX, job scheduling, emailing, and more. Also, Extreme Programming (XP), Agile Model Driven Development (AMDD) and refactoring are methods that can expedite the software development projects by reducing the amount of up front requirements and design; hence these methods are embedded throughout the book but with just enough details and examples to not sidetrack the focus of this book. In addition, this book contains well separated, subjective material (opinion sidebars), comic illustrations, tips and tricks, all of which provide real-world and practical perspectives on relevant topics. Last but not least, this book demonstrates the complete lifecycle by building and following a sample application, chapter-by-chapter, starting from conceptualization to production using the technology and processes covered in this book. In summary, by using the technologies and methods covered in this book, the reader will be able to effectively develop enterprise-class Java applications, in an agile manner!



Exploit IntelliJ IDEA’s unique features to rapidly develop web and Java Enterprise applications Overview Exhibit techniques that improve development performance Present framework support Create an application that explores the features of the integrated development environment (IDE) In Detail IntelliJ IDEA is a commercial Java development tool which competes with the free Eclipse and NetBeans projects. It is an integrated development environment (IDE) designed to automate parts of the coding process; to support a large number of different frameworks, tools, and targets; to work with multiple languages; and not to get in the way of the developer’s work. IntelliJ IDEA also does a good job of keeping up-to-date with the Java platform, subject to the expense of keeping current with the latest product version. A practical guide that will provide you with concepts and clear step-by-step exercises to help you understand and improve your performance. Through this guide, you will be able to extract more from IntelliJ IDEA 12. This book will navigate through the features of IntelliJ IDEA 12 and present the reader with concepts and tips that will give them a greater understanding of this IDE. Using a practical real-world example, readers will learn to develop one application and use some of the features presented. Through clear instructions, you will learn how to integrate the IDE with your favorite bug tracker, take a look at the refactoring approaches that IntelliJ offers, and will quickly understand and use different ways to navigate through the code. This book teaches you how to develop a web application and a simple Swing application. The development of this application will help you to understand how to work with IntelliJ's Swing GUI constructor. The book will also provide a simple code as starting point and will show you how to develop some code. What you will learn from this book Manage your tasks using (or not using) your favorite bug tracker Work with Spring framework with IntelliJ Understand and use the intentions and smart code completion features Create web services using the IntelliJ tools Install and use third party plugins Approach A practical, fast-paced guide with clear, step-by-step exercisesto help you understand the basics of IntelliJ Idea and develop a web application. Who this book is written for This book will be ideal if you are a Java developer who has a little knowledge about IntelliJ and wants to get more information on using it to improve your development performance. Product Details Paperback: 114 pages Publisher: Packt Publishing (October 17, 2013) Language: English ISBN-10: 1849699615 ISBN-13: 978-1849699617 Product Dimensions: 9.2 x 7.5 x 0.2 inches

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧