我是linux环境的新手.
我试图在linux环境中运行一个简单的hello world java类.
package com.util;
public class Hello {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("hi");
}
}
Run Code Online (Sandbox Code Playgroud)
我在windows环境下编译了java类,并将.class文件上传到linux系统到/ home/scripts路径.
我的命令如下,
java -cp /home/scripts com.util.Hello
Run Code Online (Sandbox Code Playgroud)
当我从相同的/ home/scripts执行此命令时,我正在获取Hello.class,
错误:无法找到或加载主类com.util.Hello而无法继续进行.
有人能在这个问题上帮助我吗?
我是MQTT的新手.
我在java中实现MQTT,我使用下面的代码让发布者发布到特定主题,
public void publish()
{
MqttClient myClient = null;
MqttConnectOptions connOpt;
try {
// Subscription with Brokers
connOpt = new MqttConnectOptions();
connOpt.setAutomaticReconnect(true);
connOpt.setCleanSession(true);//if your not setting cleanSession to false then subscriptions shouldn't be persisted.
String clientID = UUID.randomUUID().toString().replace("-", "");
System.out.println("clientID " + clientID);
myClient = new MqttClient("tcp://192.168.10.500:1883", clientID);
myClient.connect(connOpt);
String myTopic = "Device1";
MqttTopic topic = myClient.getTopic(myTopic);
int pubQoS = 0;
MqttMessage message = new MqttMessage("mqttMessage".getBytes());
message.setQos(pubQoS);
message.setRetained(false);
MqttDeliveryToken token = null;
token = topic.publish(message);
System.out.println("publish successful with the …Run Code Online (Sandbox Code Playgroud) 我这样对待Json,
[
{
"y": "2014",
"m": "1313",
"rowKey": "2014_13",
"key": "m",
"value": "13 "
},
{
"y": "2014",
"m": "1313",
"rowKey": "2014_13_1",
"key": "m",
"value": "13 "
},
{
"y": "2014",
"m": "1313",
"rowKey": "2014_13_2",
"key": "m",
"value": "13 "
}
Run Code Online (Sandbox Code Playgroud)
]
我尝试根据键和值传递从json中删除条目作为输入,这样,
function findAndRemove(array, property, value) {
for(var i=0;i<array.length;i++){
delete array[i].y;
delete array[i].m;
delete array[i].rowKey;
delete array[i].key;
delete array[i].value;
}
}
Run Code Online (Sandbox Code Playgroud)
我删除的json是这样的,[{},{},{}]
我希望它是这样的,删除了Json [].
即,从JSon中删除完整的条目,而不仅仅是键和值.
我也试过这种方式,
function findAndRemove(array, property, value) {
$.each(array, function(index, result) {
if(undefined != result[property] …Run Code Online (Sandbox Code Playgroud) 我使用itextsharp生成PDF文件,
我正在打印2个字符串leading1和leading2.
问题是,当领先1长度增加时,它影响领先2并且它被修剪.
但是如果在leading1中没有字符增加,我想在下一行打印leading1和leading2.
基本上,leading2被硬编码为=你的DIDIT.但是leading1是动态价值.
所以,我只想知道如何定位和包装长文本.
这是我的代码......
有人可以帮我这样做吗?
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
cb.beginText();
cb.setFontAndSize(baseFontMedium, 10f);
// float x = 6.4392f * commonView.INCH;
float x = 6.47f * commonView.INCH;
float y = pageSize.getHeight() - (1.13f * commonView.INCH);
cb.setCMYKColorFillF(0f, 0f, 0f, 0.77f);
cb.setTextMatrix(1, 0, 0, 1, x, y);
cb.showText(leading1);
x += new Chunk(leading1, fontMedium10Pt).getWidthPoint();
cb.setCMYKColorFillF(1f, 0f, 0f, 0f);
cb.setTextMatrix(1, 0, 0, 1, x, y);
cb.showText(leading2);
cb.endText();
cb.restoreState()
Run Code Online (Sandbox Code Playgroud) 我以这种方式将 2 个字符串组合到段落中,
String str2="";
String str1="";
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(36, 600, 600, 800);
ct.addElement(new Paragraph(str1 + str2));
int status1 = ct.go();
Run Code Online (Sandbox Code Playgroud)
问题是我的 str1 和 str2 的字体颜色相同。
我想要 str1 和 str2 具有不同的字体颜色和大小..
我怎样才能在ColumnText/Paragraph上做到这一点?
有人可以帮我吗...
我从外部源获取日期作为输入,它是一个字符串,
const a = '08-01-2019';
Run Code Online (Sandbox Code Playgroud)
我所需的格式是“MM-DD-YYYY”,
const outputDateFormat = 'MM-DD-YYYY';
Run Code Online (Sandbox Code Playgroud)
我正在使用 moment.js 并在该日期执行以下操作,例如添加一年和减少一天,
//adding a year
const a = moment(a).add(1, 'years').add(-1, 'days').format(outputDateFormat);
Run Code Online (Sandbox Code Playgroud)
对于上面的行,我得到,
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format.
moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release.
Run Code Online (Sandbox Code Playgroud)
我的意思是,使用 moment 转换为我的输出所需格式会给出已弃用的警告。
const finalDate = moment(a).format(outputDateFormat); - Resulting depricated warning
Run Code Online (Sandbox Code Playgroud)
因此,我尝试使用如下所示的 new …
我正在尝试解析日期字符串,OffsetDateTime如下所示.
但我得到以下异常,
线程"main"中的异常java.time.format.DateTimeParseException:无法在索引0处解析文本'Mon Jun 18 00:00:00 IST 2012'
public class ParseExample {
public static void main(String... args) throws ParseException {
String dateStr = "Mon Jun 18 00:00:00 IST 2012";
System.out.println(OffsetDateTime.parse(dateStr));
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个错误.
谢谢.