我正在尝试用Java实现某种MVC.实际上它更像是一个MVP,但这对我的问题并不重要.
以下情况:我有一个用Netbeans制作的GUI(因为更好的GUIeditor),它经常更新和更改.
由于我的主项目在Eclipse中更易于维护,因此我选择将Netbeans项目作为单独项目导入Eclipse.所以这里我的项目" App"包含控制器和模型包以及GUI包含视图包的项目" ".问题是我遵循的模式在视图和控制器之间具有循环依赖性.每当视图发生更改时,控制器都会收到通知,决定从模型中获取哪些数据,然后对视图进行更改.
当我添加App到构建路径GUI和反过来时,我将最终得到此错误消息"在项目'GUI'的构建路径中检测到循环".我的意思是,这个循环已经在我的设计中了.
目前在启动时我通过以下方式向其控制器注册视图(这不是真正的代码,我试图缩短它)
package view;
import controller.*;
class viewA{
...
public viewA() {
controllerA.register(this);
}
...
}
package controller;
import view.*;
class controllerA implements SomeListener{
...
protected viewA[] registeredViews;
public static register(viewA interestedView){
arrayPush(registeredViews,interestedView);
interestedView.addSomeListener(this)
}
...
}
Run Code Online (Sandbox Code Playgroud)
因此,您可以通过将引用传递给控制器,然后将侦听器注册到此视图来进行连接.问题是:如果我没有GUI在项目App的构建路径导入不能得到解决,同样的情况,对于没有App在GUI构建路径.
我想保留这个项目结构,并坚持我的MVC架构.我该如何解决这个问题?你有什么建议?
嗨,大家好,
/ tomcat_lib下有一个abc.jar.我需要在我的def.java中使用它
我累了
javac -classpath/tomcat_lib/-d ../classes def.java
但它不起作用
但是,如果我使用它可行
javac -classpath /tomcat_lib/abc.jar -d ....
谁能帮忙解释一下呢?
假设我们有:
为什么传递机制不适用于Eclipse IDE,以便A知道commons-collections.jar,即使没有在自己的.classpath文件中指定它也是如此.
我知道Maven可以提供这个功能,但是为什么像Eclipse(或IntelliJ;)这样的IDE不会默认?
有缺点吗?是否因为检查类路径中的每个元素而避免性能下降?
从openni编译演示时我偶然发现了这个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no OpenNI.jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.OpenNI.NativeMethods.<clinit>(NativeMethods.java:34)
at org.OpenNI.Context.initFromXmlEx(Context.java:317)
at org.OpenNI.Context.createFromXmlFile(Context.java:36)
at kitouch.UserTracker.<init>(UserTracker.java:113)
at kitouch.UserTrackerApplication.main(UserTrackerApplication.java:46)
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)
Run Code Online (Sandbox Code Playgroud)
我在我的Mac上这样做.我最好的猜测是这个文件libOpenNI.jni.dylib不在我的java.library.path中
我现在的问题是:这是猜对了,我如何libOpenNI.jni.dylib在netbeans中添加到我的java.library.path.
Thx提前
插件xyz应该在Java项目之上运行并生成一些Java代码.这段代码需要在构建和运行时插件的jar中提供的类.因此,插件的jar(或安装目录)应该出现在构建类路径中.
一个插件如何找到它自己的jar /安装目录的确切路径,或者就此而言,以便携方式找到一些相关插件jar的路径?
背景是我想制作一个用户可以运行的向导来启用项目的xyz特性.应为用户提供有意义的默认值,以便在何处查找所需的运行时功能,并将给定的库添加到构建路径中.
我正在使用Tridion 2011实现DD4T MVC3.我已经实现了它并且它正常工作到上周五.我能够获取页面模型并使用Razor视图呈现它.
但是今天周末之后,当我试图运行相同的应用程序时,我得到以下错误(从两行开始).
Tridion许可证将于今天(2012年4月30日)到期.这会有问题吗?但Tridion Content Manager工作正常.
Could not initialize class com.tridion.storage.StorageManagerFactory
================================================
Some configured classpath roots cannot be found
================================================
ClassPath : C:\MyProjects\DD4TMVC\FirstDD4TMVCApplication\FirstDD4TMVCApplication\bin\bin
============================================================
Some Java classes or interfaces could not be found or loaded
The most typical reasons for this problem are:
- you forgot to configure a classpath
- a jarfile, zipfile, or directory is missing from your
classpath
- you have a typo in one of your classpath entries
- a jarfile required by one of …Run Code Online (Sandbox Code Playgroud) 标题有这一切,在设置程序使用的类路径时,.:构造的意义是什么?
考虑
/Library/Java/Home/bin/java -cp $APP_HOME/lib/*.jar:: Handler
Run Code Online (Sandbox Code Playgroud)
VS
/Library/Java/Home/bin/java -cp .:$APP_HOME/lib/*.jar:: Handler
Run Code Online (Sandbox Code Playgroud) 我在Spring中使用freemarker.
这是我配置我的freemarker的方式:
<bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<property name="templateLoaderPath" value="classpath:/META-INF/templates"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
这个配置实际上工作正常,我能够使用模板等生成我的报告.
但是在Weblogic中,我总是得到这个例外:
15 Sep 2012 01:03:02,060 DEBUG DefaultListableBeanFactory.doCreateBean:504 - Eagerly caching bean 'freemarkerConfiguration' to allow for resolving potential circular references
15 Sep 2012 01:03:02,074 DEBUG DefaultListableBeanFactory.invokeInitMethods:1498 - Invoking afterPropertiesSet() on bean with name 'freemarkerConfiguration'
15 Sep 2012 01:03:02,228 DEBUG FreeMarkerConfigurationFactoryBean.getTemplateLoaderForPath:360 - Cannot resolve template loader path [classpath:/META-INF/templates] to [java.io.File]: using SpringTemplateLoader as fallback
java.io.FileNotFoundException: class path resource [META-INF/templates] cannot be resolved to absolute file path because it does not reside in …Run Code Online (Sandbox Code Playgroud) 我有以下目录结构:
C:\CheckinProject\sources\main\EmailProcessor.java<br/>
\compile-and-run.bat<br/>
\classes\main\EmailProcessor.class
Run Code Online (Sandbox Code Playgroud)
文件EmailProcessor.java包含以下内容:
package main;
public class EmailProcessor {
public static void main(String args[]) {
System.out.println();
}
}
Run Code Online (Sandbox Code Playgroud)
文件compile-and-run.bat包含:
javac -d ..\classes main\EmailProcessor.java
java -cp ..\classes ..\classes\main\EmailProcessor
Run Code Online (Sandbox Code Playgroud)
当我运行compile-and-run.bat时出现此错误:
Error: Could not find or load main class ..\classes\main\EmailProcessor
Run Code Online (Sandbox Code Playgroud)
为什么不能找到或加载我的主类?
我有一个foobar.jar包含以下两个类的jar文件:
public class Foo {
public static void main(String[] args) {
System.out.println("Foo");
}
}
Run Code Online (Sandbox Code Playgroud)
另一个类看起来像这样:
import javax.batch.api.chunk.ItemProcessor;
public class Bar implements ItemProcessor {
public static void main(String[] args) {
System.out.println("Bar");
}
@Override
public Object processItem(Object item) throws Exception {
return item;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用以下命令执行程序,程序将按预期运行并打印Foo:
$ java -cp foobar.jar Foo
Foo
$
Run Code Online (Sandbox Code Playgroud)
但是如果我尝试使用类中的main方法启动程序Bar,JVM会输出启动错误并退出:
$ java -cp foobar.jar Bar
Error: Could not find or load main class Bar
$
Run Code Online (Sandbox Code Playgroud)
这是同样的错误,就好像我会尝试使用不在jar中的类来启动程序,例如
$ java -cp foobar.jar BarNotThere
Error: …Run Code Online (Sandbox Code Playgroud) classpath ×10
java ×8
eclipse ×3
architecture ×1
classloading ×1
compilation ×1
dd4t ×1
dependencies ×1
freemarker ×1
jvm ×1
netbeans ×1
openni ×1
tridion ×1