我从不工作JMS.最近我下载Activemq和从没有改变端口61616到61617所有conf/activemq-*.xmlfiles.I在浏览器中运行的命令提示符,然后打开控制台页面下面的命令.
C:\Users\Infratab Bangalore\Desktop\Queueing\apache-activemq-5.8.0\bin>activemq
Run Code Online (Sandbox Code Playgroud)

现在我想给使用Java代码的消息JMS来Activemq.对于这一点,我写了下面的代码.并使用Apache Tomcat server.it运行我的代码
此代码在Eclipse中实现.
package PackageName;
import java.io.IOException;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.activemq.ActiveMQConnectionFactory;
public class MessageProducer extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
try {
//created ConnectionFactory object for creating connection
ConnectionFactory factory = new ActiveMQConnectionFactory("admin", "admin", "tcp://localhost:61617");
//Establish the connection …Run Code Online (Sandbox Code Playgroud) 我在Java中创建了一个名为Chick的类.其中包含三个变量,名称和两个声音.我有一个名为getSound()的方法,每次都会返回相同概率的声音.我该怎么做?
我的示例代码在这里:
class Chick implements Animal {
private String myType;
private String mySound;
private String mySound2;
public Chick(String type, String sound,String sound2)
{
myType = type;
mySound = sound;
mySound2=sound2;
}
public String getSound()
{
return mySound;
}
}
Run Code Online (Sandbox Code Playgroud)
我必须在getSound方法中做出哪些改变?请帮我详细解答.如果可以,请写下具有适当要求的方法.
我有以下课程来创建和管理一个Logger.每当跨代码和程序执行时,都会使用对静态getLogger() catch块的调用来记录.
public class Log {
private static final Logger logger = Logger.getLogger("MyLog");
public static void iniciarLog() throws IOException {
FileHandler fh;
try {
// fh = new FileHandler(System.getProperty("user.home")+System.getProperty("file.separator")+"TorrentDownloader.log");
fh = new FileHandler("%h/TorrentDownloader.log");
logger.addHandler(fh);
SimpleFormatter formatter = new SimpleFormatter();
fh.setFormatter(formatter);
logger.info("Se inició el log");
} catch (SecurityException | IOException e) {
logger.severe("Error al crear el log");
}
}
public static Logger getLogger() {
return logger;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如何附加到此类日志文件?我见过的所有例子都改变了很多我喜欢的实现,因为它清晰,简洁.
我是extjs的新手,特别是4版本:
我创建了一个类:
Ext.define('MyPanel', {
extend:'Ext.panel.Panel',
views: ["MyPanel"],
config: {
width: 200,
height: 300,
title: "HELLO"
},
constructor:function(config) {
this.initConfig(config);
return this;
},
alias: 'widget.MyPanel'
});
Run Code Online (Sandbox Code Playgroud)
接下来,我想在tabPanel项目中以XTYPE的形式调用此类:[]:
我这样做:
items: [{
title: 'Kontakt',
id: 'kontaktTab',
closable:true,
closeAction: 'hide',
layout: 'fit',
items:[{
xtype: "MyPanel"
}]
Run Code Online (Sandbox Code Playgroud)
没有运气,我得到的只是:
Cannot create an instance of unrecognized alias: widget.MyPanel"
你必须想,什么是菜鸟...... ;-)
有人请帮忙!!!
我在Eclipse中运行我的applet没有问题,但是如果我在浏览器中签名并运行它就会发生这种情况
10-abr-2013 19:54:37 org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Unknown proxy type : HTTP
10-abr-2013 19:54:37 org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: Retrying connect
…
java.net.SocketException: Unknown proxy type : HTTP
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
在这里我试图使用org.apache.http.client.HttpClient上传一些文件
public static String executeMultiPartRequest(String urlString, File file,
String fileName, String fileDescription) {
System.out.println("SET URI " + urlString);
HttpPost postRequest = new HttpPost(urlString);
try {
MultipartEntity multiPartEntity = new MultipartEntity();
// The usual form parameters can be added this …Run Code Online (Sandbox Code Playgroud) 我按空格分割这个字符串:( String input = ":-) :) :o) :] :3 :c) :> =] 8) =) :} :^)";表情符号之间的空格)
结果是:
:-)?:)?:o)?:]?:3?:c)?:>
=]
8)
=)?:}?:^)
Run Code Online (Sandbox Code Playgroud)
结果中有一些奇怪的字符.我不知道为什么.请帮我.
这是代码:
fileReader = new BufferedReader(new FileReader("emoticon.txt"));
String line = "";
while ((line = fileReader.readLine()) != null){
String[] icons = parts[0].split("\\s+");
....
}
Run Code Online (Sandbox Code Playgroud)
感谢任何建议.这是表情符号文件:https:
//www.dropbox.com/s/6ovz0aupqo1utrx/emoticon.txt
我正在编写一个打开文本文件并检查注释的程序。然后它解析评论以检查某些单词。
我遇到的错误是以下 while 循环,该循环检查当前行是否以空格或“/”以外的任何字符开头(如果存在非反斜杠字符),然后 while 循环移动到下一行并检查再次。一旦 while 循环满足其要求并中断程序崩溃,我会收到以下输出错误。
import java.rmi.Naming;
import java.net.InetAddress;
i
import java.lang.reflect.*;
i
ERROR: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at ExtraCredit.main(ExtraCredit.java:22)</code></pre>
Run Code Online (Sandbox Code Playgroud)
这是有问题的代码示例
System.out.println(line);
char x = line.charAt(0);
while((line.charAt(0)!='/')&&(Character.isWhitespace(x)==false))
{
line = inputFile.nextLine();
x = line.charAt(0);
System.out.println(line);
System.out.println(x);
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助。我确信这是一个简单的错误,但我只是没有看到它。
我试图了解Jax-WS Web服务如何工作,但无法找到有关它们细节的任何资源.举例来说:
我使用Jax-WS注释创建了一个非常简单的Java Web服务,就像这样
@WebService(name = "MyService", serviceName = "MyService", portName = "MyServicePort")
public class MyService {
private int val;
public MyService() {
val = 0;
}
@WebMethod(action = "setVal")
public void setVal(@WebParam(name = "arg") int arg) {
val = arg;
}
@WebMethod(action = "getVal")
public int getVal() {
return val;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我从中生成一个Web服务(比如说使用WS-Gen),那么构建一个客户端并从单个客户端进行以下调用:setVal(5),getVal()将返回给客户端的值是什么?为什么?
如果客户端A呼叫setVal(5),而客户端B呼叫getVal(),将返回给客户端的值是什么?为什么?
当然,我可以自己构建一个Web服务并对其进行测试,但我希望能够通过探索来解决问题.Jax-Ws是否为每个请求创建了带注释类的新实例?它是否以某种方式将相同的源映射到相同的带注释的类实例?它只是将所有请求映射到带注释的类的单例实例吗?是否存在以某种方式选择的有限注释类实例池?
我有这段代码:
class Base {
public Base() {
method();
}
void method() {
System.out.println("In Base");
}
}
class Derived extends Base {
private String bar;
public Derived() {
bar="bar";
}
public void method() {
System.out.println(bar.length());
}
public static void main(String[] args) {
Base base=new Derived();
base.method();
}
}
Run Code Online (Sandbox Code Playgroud)
在执行代码时,我得到了一个异常:
Exception in thread "main" java.lang.NullPointerException
at Derived.method(Main.java:22)
at Base.<init>(Main.java:5)
at Derived.<init>(Main.java:17)
at Derived.main(Main.java:27)
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么会有NullPointerException和stackTrace异常的.有人可以帮我理解吗?
你可以在这里查看代码.
我正在搜索正则表达式 - ".(冲突副本. ".我为此编写了以下代码
String str = "12B - (conflicted copy 2013-11-16-11-07-12)";
boolean matches = str.matches(".*(conflicted.*");
System.out.println(matches);
Run Code Online (Sandbox Code Playgroud)
但我得到了例外
线程"main"中的异常java.util.regex.PatternSyntaxException:索引15附近的未闭合组.(冲突.
我知道编译器认为这(是模式组的开始.我试图(通过添加来逃避,\(但这不起作用.
谁能告诉我如何逃离(这里?