Okay I don't know how to explain this but if you look a
Players:
_Brand0n_:
'Fourm Link:': 'Null'
'Registered:': 'No'
'GamePoints:': '0'
'UUID:': 94bad256-7fa0-49c6-add1-50b61a854dc3
Reports:
'#R:': '0'
'TheeLux:': Hacking Time: Fri Jul 22 12:21:35 CDT 2016'
'Adam_Hall:': Hacking Time: Fri Jul 22 12:21:35 CDT 2016'
I need to be able to take the reports from TheeLux and Adam_Hall and print an msg saying
Adam_Hall: Hacking - Time: Fri Jul 22 12:21:35 CDT 2016
But I don't know how to take however many configuration sections and make them into strings ext. If this is confusing please post a comment and I'll try and clarify.
Related
Heavily edited/updated:
I am trying to schedule a task a long time in advance. I believe it is doing something to the process because it thinks it is not going to do anything else.
I should have used HOUR_OF_DAY for 24 hour time instead of hour, but still doesn't work correctly.
New code:
public class OtherMainClass {
private static Timer timer;
private static Calendar cal;
public static void main(String[] args) throws InterruptedException {
cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
cal.set(Calendar.HOUR_OF_DAY, 8);
cal.set(Calendar.MINUTE, 0);
System.out.println("Changed to: " + cal.getTime());
timer = new Timer();
System.out.println("current time is: " + Calendar.getInstance().getTime());
System.out.println("Scheduled for: " + cal.getTime());
timer.schedule(new MyTimerTask(), cal.getTime());
timer.schedule(new MyTimerCheckTask(), 0, 1000*60*10);
}
public static class MyTimerTask extends TimerTask {
#Override
public void run() {
System.out.println("in run at: " + Calendar.getInstance().getTime());
}
}
public static class MyTimerCheckTask extends TimerTask {
#Override
public void run() {
System.out.println("cal at: " + Calendar.getInstance().getTime() + " is: " + OtherMainClass.cal.getTime());
}
}
}
Commandline output (following "is:" is the calendar object passed into the schedule.):
Changed to: Fri Feb 14 08:00:41 GMT 2020
current time is: Thu Feb 13 23:25:41 GMT 2020
Scheduled for: Fri Feb 14 08:00:41 GMT 2020
cal at: Thu Feb 13 23:25:41 GMT 2020 is: Fri Feb 14 08:00:41 GMT 2020
cal at: Thu Feb 13 23:35:41 GMT 2020 is: Fri Feb 14 08:00:41 GMT 2020
cal at: Thu Feb 13 23:45:41 GMT 2020 is: Fri Feb 14 08:00:41 GMT 2020
cal at: Thu Feb 13 23:55:41 GMT 2020 is: Fri Feb 14 08:00:41 GMT 2020
cal at: Fri Feb 14 09:39:27 GMT 2020 is: Fri Feb 14 08:00:41 GMT 2020
in run at: Fri Feb 14 09:39:27 GMT 2020
Note the very interesting run at the end, as well as the other task running. I clicked on commandline, which turned it into select mode, then control-c to exit that, then a few seconds later, it did both Tasks. (It should have run long before I clicked on commandline.
Java version from java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
OS: Windows 10
I ran a test stating Friday around 11:30. I changed the windows sleep settings set to 1 hour (Start -> Settings -> System -> Power & sleep). Since Friday 8:00 had passed, I changed the day to Saturday. I also changed the repeated interval to every half hour 3*1000*60*10, since I wanted to limit the lines of output. I ran the code in 5 different Command Prompts and started them at around 11:30 Friday:
No QuickEdit Mode. The program was running and I had to Crtl-c to stop it. No printout to the screen after sleep initiated. (Admittedly I didn't wait to see if it would print the 8 o'clock message after some time, because it seemed pointless.)
QuickEdit Mode. Did not click inside the screen. Same as 1.
QuickEdit Mode. Clicked inside the screen and immediately cancelled with Ctrl^c. The prompt top bar changed to "Select Command Prompt.." and went back to "Command Prompt..". Same as 1.
QuickEdit Mode. Clicked inside the screen and highlighted some test. The prompt top bar changed to "Select Command Prompt". There was absolutely no printout after that until I pressed Ctrl^c and the printouts were as if I had just started the program and it just printed the below. However I did not just exit the program, and it resumes the 30 min interval printout, as you can see from the below:
QuickEdit Mode. Clicked inside the screen (that's all). The prompt top bar changed to "Select Command Prompt". Same as 4.
This is the result of 4 and 5, that only started printing after i exited "Select Command Prompt"-mode at 9:43 on Saturday:
Changed to: Sat Feb 15 08:00:16 CET 2020
current time is: Sat Feb 15 09:49:13 CET 2020
Scheduled for: Sat Feb 15 08:00:16 CET 2020
in run at: Sat Feb 15 09:49:13 CET 2020
cal at: Sat Feb 15 09:49:13 CET 2020 is: Sat Feb 15 08:00:16 CET 2020
cal at: Sat Feb 15 10:19:13 CET 2020 is: Sat Feb 15 08:00:16 CET 2020
cal at: Sat Feb 15 10:49:13 CET 2020 is: Sat Feb 15 08:00:16 CET 2020
cal at: Sat Feb 15 11:19:13 CET 2020 is: Sat Feb 15 08:00:16 CET 2020
...
I ran another test with the windows sleep setting set to "Never". Since Saturday 8:00 had passed, I changed the day to Sunday. I again ran the code in 5 different Command Prompts and started them at around 15:30 Saturday:
No QuickEdit Mode. Worked without issues. See below.
QuickEdit Mode. Did not click inside the screen. Same as 1.
QuickEdit Mode. Clicked inside the screen and immediately cancelled with Ctrl^c. The prompt top bar changed to "Select Command Prompt.." and went back to "Command Prompt..". Same as 1.
QuickEdit Mode. Clicked inside the screen and highlighted some test. The prompt top bar changed to "Select Command Prompt". There was absolutely no printout after that. Until I pressed Ctrl^c and the printout was identical to the test above.
QuickEdit Mode. Clicked inside the screen (that's all). The prompt top bar changed to "Select Command Prompt". There was absolutely no printout after that.
Result:
Changed to: Sun Feb 16 08:00:31 CET 2020
current time is: Sat Feb 15 15:35:31 CET 2020
Scheduled for: Sun Feb 16 08:00:31 CET 2020
cal at: Sat Feb 15 15:35:31 CET 2020 is: Sun Feb 16 08:00:31 CET 2020
cal at: Sat Feb 15 16:05:31 CET 2020 is: Sun Feb 16 08:00:31 CET 2020
..snip..
cal at: Sun Feb 16 07:05:31 CET 2020 is: Sun Feb 16 08:00:31 CET 2020
cal at: Sun Feb 16 07:35:31 CET 2020 is: Sun Feb 16 08:00:31 CET 2020
in run at: Sun Feb 16 08:00:31 CET 2020
cal at: Sun Feb 16 08:05:31 CET 2020 is: Sun Feb 16 08:00:31 CET 2020
The answer by Shaun Rowan to Why is my command prompt freezing on Windows 10? you provided mentions:
whenever you click on a command window in windows 10, it immediately halts the application process when it attempts to write to the console
So it doesn't seem to be a bug in the Command Prompt either, rather it's a feature.
As per Will my Window 10 apps continue to update or download on sleep or hibernation mode? by A. User:
Sleep is a power-saving state that allows a computer to quickly resume full-power operation (typically within several seconds) when you want to start working again. Putting your computer into the sleep state is like pausing a DVD player—the computer immediately stops what it’s doing and is ready to start again when you want to resume working.
If you're very interested in Windows sleep modes TechRepublic has an article on Investigating Sleep states in Windows 10 describes the 6 stages of sleep, from when the (processor clocks are stopped) -> (the processor shuts off to save power) -> (other chips on the motherboard may shut off)
Conclusion:
If you want your java program to keep executing, ensure your Command Prompt window is not in "Select Command Prompt.."-mode and also ensure that your computer does not enter sleep mode, as either of these will halt execution of the program.
I am trying to do the implementation of opc ua client using eclipse milo sdk and the reference link am using is:
https://community.hortonworks.com/questions/176894/opc-ua-client-performance-with-eclipse-milo.html
for the Publish/Subscribe code since am having multiple nodes am not able to make out the data that I get corresponds to which node id and also the timestamp I am getting am not able to make out its in which format.
Item: org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaMonitoredItem#2b2c39b1
Value: DataValue{value=Variant{value=11}, status=StatusCode{name=Good, value=0x00000000, quality=good},
sourceTime=DateTime{utcTime=131771575305048867, javaDate=Fri Jul 27 15:02:10 IST 2018},
serverTime=DateTime{utcTime=131771575305048867, javaDate=Fri Jul 27 15:02:10 IST 2018}}
and when am using Async Read code am not getting timestamp.
[DataValue{value=Variant{value=3},
status=StatusCode{name=Good, value=0x00000000, quality=good}, sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}, serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}},
DataValue{value=Variant{value=11}, status=StatusCode{name=Good, value=0x00000000, quality=good}, sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601},
serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}},
DataValue{value=Variant{value=8}, status=StatusCode{name=Good, value=0x00000000, quality=good},
sourceTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}, serverTime=DateTime{utcTime=0, javaDate=Mon Jan 01 05:30:00 IST 1601}}]
can anyone give me some idea on where am going wrong?
It might be easier to understand if you started with the examples from Milo itself, rather than a random benchmark someone wrote using Milo that you happened to stumble across.
Check out the examples:
Subscribe Example
Read Example
I am working on a tool which uses ews-java-api to create, update and delete calendar items in Outlook agenda. It has been working fine, but now sometimes when it tries to update some calendar item, I get following error:
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:879)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:796)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:286)
at java.lang.Thread.run(Thread.java:745)
Recently all the exchange accounts have been migrated from local Outlook servers to Office365 cloud servers. Maybe this has something to do with it? Or anybody have any idea on what is going wrong?
Following code is to perform the update for an item:
Item it = alitems.get(i);
...
it.update(ConflictResolutionMode.AlwaysOverwrite);
Following is the url being used to access office365 ews:
exchangewebservice = https://outlook.office365.com/EWS/Exchange.asmx
Thanks in advance
Edit: I use ews-java-api version 2.0
Edit: Here you can see that the error occurs on one line and than the next line, with the same recipient it doesn't occur...
microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:880)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:703)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:283)
at java.lang.Thread.run(Thread.java:745)
WARN be.vrt.quintiqexchange.main.QuintiqAdapter - At least one recipient isn't valid., A message can't be sent because it contains no recipients.by UPDATE for subject: on Thu Jun 23 14:00:00 CEST 2016 Thu Jun 23 19:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: NIET DAG on Fri Aug 05 10:00:00 CEST 2016 Fri Aug 05 18:00:00 CEST 2016 of user name.lastname#domain.com
INFO be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: PROEF st5 on Mon Aug 22 10:00:00 CEST 2016 Mon Aug 22 20:30:00 CEST 2016 of user name.lastname#domain.com
This means that the recipient isn't really the issue, I guess...
p.s. I replaced the original mailaddress but believe me, it's a correct mailadres :)
In my case, if the address is not properly trimmed and has any whitespace characters at all, EWS vomits this exception up.
I have a problem concerning the .jar Export. I have to include a .txt file into my jar from where I read words into a list. I used this to realize(in eclipse Run + Debug mode it works well):
File file = new File(Worte.class.getClassLoader().getResource("resource/wortliste.txt").getFile());
Now, if I export it into a JAR file, the JAR file is executable as it should, and it contains the list.txt and .java files in resource (as it should because it's homework ;-) ), but the program behaves like there was no file. I have the same problem when i use getResourceAsStream(). Does anybody know why this won't work? I don't understand that, because i did this 2 weeks ago with another code, and it worked o_O.
What i have tried:
deleting the Project and import into a new one
like 1, but into a new workspace
My System is a Windows 7 x64 PC, Eclipse Juno and JRE7.
Options I use for export:
[] Export generated class files and resources
[x] export all output folders...
[x] export java source files...
[] export refactorings
[x] compress the contents...
[x] add directory entries
[x] overwrite existing files without warning
jar tvf ...
39 Wed Jan 30 16:19:14 CET 2013 META-INF/MANIFEST.MF
0 Wed Jan 30 00:34:16 CET 2013 resource/
100250 Wed Jan 30 00:37:24 CET 2013 resource/wortliste.txt
0 Wed Jan 30 00:34:16 CET 2013 wortspiel/
1291 Wed Jan 30 01:19:14 CET 2013 wortspiel/BuchstabenKollektion.java
2251 Sun Jan 27 16:24:42 CET 2013 wortspiel/TestBuchstabenKollektion.java
506 Sun Jan 27 17:38:48 CET 2013 wortspiel/UI.java
1187 Sun Jan 27 16:24:42 CET 2013 wortspiel/TestWorte.java
2932 Wed Jan 30 01:25:00 CET 2013 wortspiel/WortspielGUI.java
4384 Wed Jan 30 01:50:40 CET 2013 wortspiel/Worte.java
310 Sun Jan 27 16:25:08 CET 2013 .classpath
383 Sun Jan 27 16:22:32 CET 2013 .project
1992 Wed Jan 30 16:02:12 CET 2013 wortspiel/BuchstabenKollektion.class
2075 Wed Jan 30 16:02:12 CET 2013 wortspiel/TestBuchstabenKollektion.class
1104 Wed Jan 30 16:02:12 CET 2013 wortspiel/TestWorte.class
942 Wed Jan 30 16:02:12 CET 2013 wortspiel/UI.class
4701 Wed Jan 30 16:02:12 CET 2013 wortspiel/Worte.class
688 Wed Jan 30 16:02:12 CET 2013 wortspiel/WortspielGUI$1.class
688 Wed Jan 30 16:02:12 CET 2013 wortspiel/WortspielGUI$2.class
3475 Wed Jan 30 16:02:12 CET 2013 wortspiel/WortspielGUI.class
You can't use java.io.File to get the contents of a file inside of a jar. Try running the following snippet,
public class TestGetResource
{
public static void main(String[] args) throws Exception
{
URL url = TestGetResource.class.getResource("/resource/wortliste.txt");
System.out.println("URL: " + url);
File f = new File(url.getFile());
System.out.println("File: " + f);
System.out.println("File exists: " + f.exists());
try {
FileReader reader = new FileReader(f);
reader.read();
} catch (FileNotFoundException notFoundEx) {
System.out.println("Caught FileNotFoundException: " + notFoundEx.getMessage());
}
}
}
You should see something similar to this,
URL: jar:file:/C:/some/path/my.jar!/resource/wortliste.txt
File: file:\C:\some\path\my.jar!\resource\wortliste.txt
File exists: false
Caught FileNotFoundException: file:\C:\some\path\my.jar!\resource\wortliste.txt (The filename, directory name, or volume label syntax is incorrect)
Instead, use Class.getClassLoader().getResourceAsStream(String) to get an InputStream for reading the file. If you still need to read the contents as a File, you could stream the contents out to a temp file.
Try this:
URL url = Thread.currentThread().getContextClassLoader().getResource("resource/list.txt");
File file = new File(url.getFile());
Basically i have built an appointment scheduler webapp using java servlets.
It relies heavily on javas Calendar.
The whole thing was developed on my macbook running mountain lion with jdk 1.6.
Now when testing it on my pc i have had some strange results.
Running:
System.out.println("selected = "+selected);
Calendar now = Calendar.getInstance();
System.out.println("a "+now.getTime());
now.setTimeInMillis(selected);
System.out.println("b "+now.getTime());
now.set(Calendar.MILLISECOND,0);
now.set(Calendar.SECOND,0);
now.set(Calendar.MINUTE,0);
now.set(Calendar.HOUR_OF_DAY,6);//start from 6am
System.out.println("d "+now.getTime());
now.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
System.out.println("e "+now.getTime());
on the PC will output:
selected = 1355835600000
a Wed Dec 19 19:35:36 EST 2012
b Wed Dec 19 00:00:00 EST 2012
d Wed Dec 19 06:00:00 EST 2012
e Sun Dec 23 06:00:00 EST 2012
Yet on the mac it will output:
selected = 1355835600000
a Wed Dec 19 19:33:57 EST 2012
b Wed Dec 19 00:00:00 EST 2012
d Wed Dec 19 06:00:00 EST 2012
e Sun Dec 16 06:00:00 EST 2012
As we can see here, if i build a table representing a weekly schedule off these values, the mac will start at 6am on the sunday contained in the current week.
But the pc will start at 6am on the sunday contained in the next week.
Which means any appointments i create are out of sync on the pc (different days to whats expected)
note: the pc has been tested with both jdk1.6 and jdk1.7
Does anyone know any solutions or reasons behind this?
Thanks
Possibly, this is a locale/timezone problem which might differ on both machines.
Make sure that both instances use the same locale by hard coding it for example:
Calendar.getInstance(Locale.US);
else getInstance() would use the default locale of your system.