我跟着这个帖子
现在,当我尝试使用maven插件安装构建时,我收到以下错误.我执行的目标是clean -X install
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
-> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project trojantime: Compilation failure
Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre6\..\lib\tools.jar
Please ensure you are using …Run Code Online (Sandbox Code Playgroud) 我有一个代码作为
public class BooleanTest {
public BooleanTest() {
super();
}
public static void main(String args[]){
BooleanTest bt = new BooleanTest();
bt.doProcess();
}
private boolean method() {
return false;
}
private void doProcess() {
Boolean obj = (Boolean)method();
System.out.println(obj.booleanValue());
}
}
Run Code Online (Sandbox Code Playgroud)
问题是在任何情况下都可以 System.out.println(obj.booleanValue());抛出NullPointerException?
在JNI中,我通过调用SetObjectArrayElement()在JNI代码中插入本地创建的java对象来构造一个大型数组.
我的问题是,在使用对象插入数组后SetObjectArrayElement(),数组是否存储了一个引用,以便我可以使用DeleteLocalRef来释放对插入对象的本地引用?
我正在将一些python代码转换为java,并且我需要调用一个对象的方法,但在运行时才知道哪些方法.在python中,我通过在我的对象上使用getattr并传递一个字符串来解决这个问题,该字符串是我的方法的名称.你会如何在Java中做类似的事情?
我正在使用javaeventing编写一个偶数驱动的shell来访问数据库.所以,我的用例是:
现在,我怎么能避免while(!exit){ //do stuff }这种循环呢?如何正确使用Java事件?
直截了当的方式可以是:
while(!exit)
{
exit = myClass.execute("command"); //when command is exit, return true.
}
Run Code Online (Sandbox Code Playgroud)
但是,我正在寻找java事件是否可以提供更好的解决方案.
UPDATE1:
这是我想要实现的:
1我的应用程序是一个shell(如mongodb shell)来试用一个键值数据库.
2简单的代码:
init(); //Initialize the connection with database
while(!exit)
{
//exit = myClass.execute("put(5)"); //This returns false
exit = myClass.execute("exit"); //returns true, i.e. the user wants to exit the shell
}
Run Code Online (Sandbox Code Playgroud)
现在,在这里我没有看到java事件的使用,我解决了我的问题,请你告诉我,如何在这里看到java事件?我希望用户触发事件.
问题就是这一切.如何下载java servlet和/或jsp文档并将其附加到Eclipse?
顺便说一下,我正在使用apache tomcat 6.0.32.
我想以人类可读的格式表达一些时间间隔.我正在寻找一个能自动选择正确单位大小的图书馆.间隔范围从毫秒到几周.就像是
我知道我可以手动检查参数的大小然后转换它但在重新发明轮子之前我想问一下是否有(标准)库来实现它.
编辑:
我的输入以纳秒为单位,输出如上所述.
在我的应用程序中,有一个类如下:
public class Client {
public synchronized static print() {
System.out.println("hello");
}
static {
doSomething(); // which will take some time to complete
}
}
Run Code Online (Sandbox Code Playgroud)
此类将在多线程环境中使用,许多线程可以同时调用Client.print()方法.我想知道线程1是否有可能触发类初始化,并且在类初始化完成之前,thread-2进入print方法并打印出"hello"字符串?
我在生产系统(64位JVM + Windows 2008R2)中看到了这种行为,但是,我无法在任何环境中使用简单程序重现此行为.
在Java语言规范的第12.4.1节(http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html)中,它说:
类或接口类型T将在第一次出现以下任何一个之前立即初始化:
- T是一个类,并且创建了T的实例.
- T是一个类,并且调用由T声明的静态方法.
- 分配由T声明的静态字段.
- 使用由T声明的静态字段,对字段的引用不是编译时常量(第15.28节).编译时常量的引用必须在编译时解析为编译时常量值的副本,因此使用这样的字段永远不会导致初始化.
根据这一段,类初始化将在静态方法的调用之前进行,但是,不清楚是否需要在调用静态方法之前完成类初始化.根据我的直觉,JVM应该在进入静态方法之前完成类初始化,并且我的一些实验支持我的猜测.但是,我确实在另一个环境中看到了相反的行为.有人能否对我有所了解?
任何帮助表示赞赏,谢谢.
我们正在开发一个应用程序,我们必须支持多个浏览器选项卡/窗口.我们的设置:MyFaces 2.1,Spring,Orchestra
默认情况下,org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION设置为20.这意味着如果您在浏览器中打开21个选项卡,则第一个选项卡中的页面将停止工作 - 给定视图没有视图状态.
如果在第二个选项卡中打开2个选项卡并请求21个视图更新(即Ajax事件),则会发生相同的情况.然后在第一个选项卡中单击将生成相同的异常.
有没有解决的办法?例如,是否可以将视图缓存绑定到会话范围?
看看Spring Boot:
http://projects.spring.io/spring-boot/#quick-start
似乎"快速入门"说包括:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
以下是我目前的存储库:
<repositories>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
Run Code Online (Sandbox Code Playgroud)
我得到一个连接超时异常,当我实际查看存储库时......
http://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/
Run Code Online (Sandbox Code Playgroud)
没有1.0.1!pom.xml应该包含一些其他存储库吗?
错误:
Project build error: Non-resolvable parent POM: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:1.0.0.RC5 from http://repo.spring.io/
milestone was cached in the local repository, resolution will not be reattempted until the update interval of spring-milestones has elapsed or updates are forced.
Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.0.0.RC5 from/to spring-milestones …Run Code Online (Sandbox Code Playgroud)