The ClassNotFoundException when running a jar from command line - jar

I am not sure what is missing from this jar file but when I try to run the jar from the command line, it cannot load the main entry point:
This is the directory that contains the classes and the resources for my application.
C:\Users\hrh74\Documents\ABack up\NetBeansProjects\mavenfxedittableview\target\classes\org\openjfx\mavenfxedittableview
09/04/2020 08:48 PM <DIR> .
09/04/2020 08:48 PM <DIR> ..
09/03/2020 04:24 PM 2,502 addressBookData.xml
09/02/2020 05:52 PM 9,562 Address_Book.png
09/02/2020 05:52 PM 859 birthdaystatistic.fxml
09/02/2020 05:52 PM 3,274 BirthdaystatisticController.class
09/02/2020 05:52 PM 3,224 DarkTheme.css
09/02/2020 05:52 PM 2,072 DateUtil.class
09/02/2020 05:52 PM 1,214 LocalDateAdapter.class
09/02/2020 05:52 PM 3,523 Person.class
09/02/2020 05:52 PM 4,535 personeditdialog.fxml
09/02/2020 05:52 PM 5,128 PersoneditdialogController.class
09/02/2020 05:52 PM 1,029 PersonListWrapper.class
09/02/2020 05:52 PM 6,412 personoverview.fxml
09/02/2020 05:52 PM 1,904 rootlayout.fxml
09/02/2020 05:52 PM 4,490 RootlayoutController.class
09/02/2020 05:52 PM 9,060 TableEditApp.class
09/02/2020 05:52 PM 6,812 TableVieweditController.class
16 File(s) 65,600 bytes
2 Dir(s) 57,686,331,392 bytes free
I created an app.jar for my application and specified the application's main entry class.
C:\Users\hrh74\Documents\ABack up\NetBeansProjects\mavenfxedittableview\target
\classes\org\openjfx>jar cvfe app.jar TableEditApp.class -C mavenfxedittableview .
added manifest
adding: addressBookData.xml(in = 2502) (out= 376)(deflated 84%)
adding: Address_Book.png(in = 9562) (out= 9567)(deflated 0%)
adding: birthdaystatistic.fxml(in = 859) (out= 372)(deflated 56%)
adding: BirthdaystatisticController.class(in = 3274) (out= 1544)(deflated 52%)
adding: DarkTheme.css(in = 3224) (out= 826)(deflated 74%)
adding: DateUtil.class(in = 2072) (out= 941)(deflated 54%)
adding: LocalDateAdapter.class(in = 1214) (out= 537)(deflated 55%)
adding: Person.class(in = 3523) (out= 1277)(deflated 63%)
adding: personeditdialog.fxml(in = 4535) (out= 872)(deflated 80%)
adding: PersoneditdialogController.class(in = 5128) (out= 2418)(deflated 52%)
adding: PersonListWrapper.class(in = 1029) (out= 485)(deflated 52%)
adding: personoverview.fxml(in = 6412) (out= 1149)(deflated 82%)
adding: rootlayout.fxml(in = 1904) (out= 542)(deflated 71%)
adding: RootlayoutController.class(in = 4490) (out= 2097)(deflated 53%)
adding: TableVieweditController.class(in = 6812) (out= 2835)(deflated 58%)
The app.jar created successfully. Here is the content of META-INF/MANIFEST.MF file.
Manifest-Version: 1.0
Created-By: 14.0.2 (Oracle Corporation)
Main-Class: TableEditApp.class
Here is my classpath having the current directory '.' in the beginning.
.;C:\Users\hrh74\Documents\ABack up\NetBeansProjects\javalearning\build\classes;C:\Program Files\Java\jdk-14.0.2;C:\Program Files\Java\jdk-14.0.2\bin;C:\Program Files (x86)\Java\jre1.8.0_251\bin;C:\Program Files\Java\jdk-14.0.2\lib;
When I list the content of the jar file, all the classes are properly packaged in the jar.
C:\Users\hrh74\Documents\ABack up\NetBeansProjects\mavenfxedittableview\target\classes\org\openjfx>jar tvf app.jar
0 Fri Sep 04 23:22:18 IRDT 2020 META-INF/
98 Fri Sep 04 23:22:18 IRDT 2020 META-INF/MANIFEST.MF
2502 Thu Sep 03 16:24:22 IRDT 2020 addressBookData.xml
9562 Wed Sep 02 17:52:36 IRDT 2020 Address_Book.png
859 Wed Sep 02 17:52:36 IRDT 2020 birthdaystatistic.fxml
3274 Wed Sep 02 17:52:40 IRDT 2020 BirthdaystatisticController.class
3224 Wed Sep 02 17:52:36 IRDT 2020 DarkTheme.css
2072 Wed Sep 02 17:52:40 IRDT 2020 DateUtil.class
1214 Wed Sep 02 17:52:38 IRDT 2020 LocalDateAdapter.class
3523 Wed Sep 02 17:52:38 IRDT 2020 Person.class
4535 Wed Sep 02 17:52:36 IRDT 2020 personeditdialog.fxml
5128 Wed Sep 02 17:52:40 IRDT 2020 PersoneditdialogController.class
1029 Wed Sep 02 17:52:40 IRDT 2020 PersonListWrapper.class
6412 Wed Sep 02 17:52:36 IRDT 2020 personoverview.fxml
1904 Wed Sep 02 17:52:36 IRDT 2020 rootlayout.fxml
4490 Wed Sep 02 17:52:38 IRDT 2020 RootlayoutController.class
9060 Wed Sep 02 17:52:38 IRDT 2020 TableEditApp.class
6812 Wed Sep 02 17:52:38 IRDT 2020 TableVieweditController.class
Finally, when I run the application from the command line using java –jar app.jar, I get the ClassNotFoundException.
C:\Users\hrh74\Documents\ABack up\NetBeansProjects\mavenfxedittableview\target\classes\org\openjfx>java -jar app.jar
Error: Could not find or load main class TableEditApp.class
Caused by: java.lang.ClassNotFoundException: TableEditApp.class
I tried to adhere to the spec to the best of my knowledge, so I am not sure why this is not working. Any idea, what might be causing this exception?
Thanks in advance.

I discovered something interesting in respect to the HelloWorld.java that I mentioned in my last comment. I abandoned using the "jar cvfe" and instead created a file name mymanifest.txt and placed the name of the class with the main entry as "Main-Class: org.me.HelloWorld" followed by two blank lines (per specification). I packaged the jar using the "jar cvmf" instead of "jar cvfe" and it WORKED FINE. I then applied the same method to my application jar creation, and now I am getting a Linkage Error instead of ClassNotFoundException. Perhaps, it has something to do with the JavaFX library that I have to investigate deeper. In summary, I suspect that the "jar cvfe" switch might not be working as described in the Java tutorial. I have had found errors in the tutorial in the past and this MIGHT be another one.
Anyway, thank you all for your comments.

Related

How to Extract logs between 2 timestamps in Unix

I need to extract the logs between two timestamps from a file in Unix. I basically kind of need those logs to be copied and output in a different file so that I can copy them.
Is there an efficient way to do this? The log format looks like this - The timestamp is in a separate line from the actual logs.
Tue 21 Apr 14:00:00 GMT 2020
{"items":[{"cpu.load": "0.94","total.memory": "6039.798 MB","free.memory": "4367.152 MB","used.memory": "1672.646 MB","total.physical.system.memory": "16.656 GB","total.free.physical.system.memory": "3860.197 MB","total.used.physical.system.memory": "12.796 GB","number.of.cpus": "8"}]}
Tue 21 Apr 18:00:00 GMT 2020
{"items":[{"cpu.load": "0.76","total.memory": "6039.798 MB","free.memory": "4352.656 MB","used.memory": "1687.142 MB","total.physical.system.memory": "16.656 GB","total.free.physical.system.memory": "3858.203 MB","total.used.physical.system.memory": "12.798 GB","number.of.cpus": "8"}]}
I am doing this but it only prints out the timestamp and not the actual logs
cat file.txt | awk -F, '{ if ($1>"Fri 21 Aug 14:00:00 GMT 2020" && $1<"Sat 22 Aug 18:00:00 GMT 2020") print }'
Can someone advice.

Formatting bootstrap-datepicker result

So here is how i setup my datepicker
$('#picker').datepicker({
format: 'yyyy-mm-dd',
multidate: true
});
and then here is how i showing the result
$('#picker').on('changeDate', function(event) {
console.log( $('#picker').datepicker("getDates"));
});
here is the result from console
[Tue Jun 02 2020 00:00:00 GMT+0700 (Waktu Indonesia Barat), Wed Jun 10 2020 00:00:00 GMT+0700 (Waktu Indonesia Barat), Wed Jun 17 2020 00:00:00 GMT+0700 (Waktu Indonesia Barat)]
How can i make it to yyyy-mm-dd format ?
So here is how i fix it
$('#picker').datepicker("getFormattedDate")
maybe it will help others
Give moment.js a try. It is a very powerful tool not just only to format Date objects, but to manipulate them and make custom validations.

Convert string Fri, 04 Aug 2017 13:07:44 into 04-08-2017 in unix

I would like to convert the date " Fri, 04 Aug 2017 13:07:44 GMT " into 04-08-2017 .
And code should recursively convert all string format into specified format.
You may use the -d option with date command.
Execute this in your command line to get the desired output.
date -d 'Fri, 04 Aug 2017 13:07:44 GMT' +'%d-%m-%Y'
Edit :
If you want to populate it in a script you may use something like this:
#!/bin/bash
input_date="Fri, 04 Aug 2017 13:07:44 GMT"
output_date=$(date -d "$input_date" +'%d-%m-%Y')
echo $output_date

Conversion to datetime is yielding error "ValueError: day is out of range for month" How to find

I have a huge dataframe that looks something like this:
Insider Trading Relationship Date \
SEC Form 4
Nov 16 04:06 PM Silverman Gene Director Nov 14
Oct 27 07:00 AM RAKOLTA JOHN JR Director Oct 26
Nov 16 04:09 PM LEIGHTON F THOMSON Chief Executive Officer Nov 15
Nov 02 04:20 PM Blumofe Robert EVP Platform Nov 01
Oct 28 04:03 PM MCCONNELL RICK M President Prods & Development Oct 28
I'm trying to change the index dtype into a datetime dtype via this code
pd.to_datetime(df2.index, format = '%b %d %I:%M %p')
but it's yielding the error:
Traceback (most recent call last):
File "<pyshell#126>", line 1, in <module>
pd.to_datetime(df2.index, format = '%b %d %I:%M %p')
File "C:\Python27\lib\site-packages\pandas\util\decorators.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Python27\lib\site-packages\pandas\tseries\tools.py", line 420, in to_datetime
return _convert_listlike(arg, box, format, name=arg.name)
File "C:\Python27\lib\site-packages\pandas\tseries\tools.py", line 407, in _convert_listlike
raise e
Is there a way I can find the index of where the error is occurring?
It seems I can set errors to coerce which would just return a Nan as the date, but I would like to avoid that.
Thanks!
You are right, just finish the logic. Set to coerce and filter the index against all values being isnull() to find all the incorrect indices.

FreeRADIUS Google Dual Factor Authenticator, Pam

Hi I've been following this article to setup FreeRADIUS Google Dual Factor Authenticator
http://www.supertechguy.com/help/security/freeradius-google-auth
Hours of testing I still can't get it to work. If my /etc/pam.d/radiusd looks like the following it works well with
the following command
radtest test test localhost 18120 testing123
#
# /etc/pam.d/radiusd - PAM configuration for FreeRADIUS
#
# We fall back to the system default in /etc/pam.d/common-*
#
#include common-auth
#include common-account
#include common-password
#include common-session
However if it looks like the following
#
# /etc/pam.d/radiusd - PAM configuration for FreeRADIUS
#
# We fall back to the system default in /etc/pam.d/common-*
#
##include common-auth
##include common-account
##include common-password
##include common-session
auth requisite pam_google_authenticator.so forward_pass
auth required pam_unix.so use_first_pass
my log file says the following and auth fails.
rad_recv: Access-Request packet from host 127.0.0.1 port 43185, id=111, length=56
User-Name = "test"
User-Password = "test"
NAS-IP-Address = 127.0.1.1
NAS-Port = 18120
Thu Sep 26 16:38:19 2013 : Info: # Executing section authorize from file /etc/freeradius/sites-enabled/default
Thu Sep 26 16:38:19 2013 : Info: +- entering group authorize {...}
Thu Sep 26 16:38:19 2013 : Info: ++[preprocess] returns ok
Thu Sep 26 16:38:19 2013 : Info: ++[chap] returns noop
Thu Sep 26 16:38:19 2013 : Info: ++[mschap] returns noop
Thu Sep 26 16:38:19 2013 : Info: ++[digest] returns noop
Thu Sep 26 16:38:19 2013 : Info: [suffix] No '#' in User-Name = "test", looking up realm NULL
Thu Sep 26 16:38:19 2013 : Info: [suffix] No such realm "NULL"
Thu Sep 26 16:38:19 2013 : Info: ++[suffix] returns noop
Thu Sep 26 16:38:19 2013 : Info: [eap] No EAP-Message, not doing EAP
Thu Sep 26 16:38:19 2013 : Info: ++[eap] returns noop
Thu Sep 26 16:38:19 2013 : Info: [files] users: Matched entry DEFAULT at line 74
Thu Sep 26 16:38:19 2013 : Info: ++[files] returns ok
Thu Sep 26 16:38:19 2013 : Info: ++[expiration] returns noop
Thu Sep 26 16:38:19 2013 : Info: ++[logintime] returns noop
Thu Sep 26 16:38:19 2013 : Info: [pap] WARNING! No "known good" password found for the user. Authentication may fail because of this.
Thu Sep 26 16:38:19 2013 : Info: ++[pap] returns noop
Thu Sep 26 16:38:19 2013 : Info: Found Auth-Type = PAM
Thu Sep 26 16:38:19 2013 : Info: # Executing group from file /etc/freeradius/sites-enabled/default
Thu Sep 26 16:38:19 2013 : Info: +- entering group authenticate {...}
Thu Sep 26 16:38:19 2013 : Debug: pam_pass: using pamauth string <radiusd> for pam.conf lookup
Thu Sep 26 16:38:19 2013 : Debug: pam_pass: function pam_authenticate FAILED for <test>. Reason: Cannot make/remove an entry for the specified session
Thu Sep 26 16:38:19 2013 : Info: ++[pam] returns reject
Thu Sep 26 16:38:19 2013 : Info: Failed to authenticate the user.
Thu Sep 26 16:38:19 2013 : Info: Using Post-Auth-Type Reject
Thu Sep 26 16:38:19 2013 : Info: # Executing group from file /etc/freeradius/sites-enabled/default
Thu Sep 26 16:38:19 2013 : Info: +- entering group REJECT {...}
Thu Sep 26 16:38:19 2013 : Info: [attr_filter.access_reject] expand: %{User-Name} -> test
Thu Sep 26 16:38:19 2013 : Debug: attr_filter: Matched entry DEFAULT at line 11
Thu Sep 26 16:38:19 2013 : Info: ++[attr_filter.access_reject] returns updated
Thu Sep 26 16:38:19 2013 : Info: Delaying reject of request 0 for 1 seconds
Thu Sep 26 16:38:19 2013 : Debug: Going to the next request
Thu Sep 26 16:38:19 2013 : Debug: Waking up in 0.9 seconds.
Thu Sep 26 16:38:20 2013 : Info: Sending delayed reject for request 0
Sending Access-Reject of id 111 to 127.0.0.1 port 43185
Thu Sep 26 16:38:20 2013 : Debug: Waking up in 4.9 seconds.
Thu Sep 26 16:38:25 2013 : Info: Cleaning up request 0 ID 111 with timestamp +3
Thu Sep 26 16:38:25 2013 : Info: Ready to process requests.
I'm using Ubuntu latest
Does anyone know what the issue here?
Many Thanks
After so much internet surfing and forum hunting I manage to fix this problem. If anyone else having this issue this might help them :)
Thu Sep 26 16:38:19 2013 : Debug: pam_pass: using pamauth string <radiusd> for pam.conf lookup
Thu Sep 26 16:38:19 2013 : Debug: pam_pass: function pam_authenticate FAILED for <test>. Reason: Cannot make/remove an entry for the specified session
The above line actually means a auth fail, even though it doesn't sound like it, also it could mean that .google_authenticator file in the user's home directory isn't accessible.
FreeRadius log file not help you much with this issue, but have a look through /var/log/secure on CentOS and /var/log/auth.log in Ubuntu. This will explain which is the issue.
Issue with my system was my time was out and my random generated number by Google Dual Factor Authenticator application on my iPhone wasn't valid. I had to install NTP and change my servers time to the correct time which fixed the issue!!!!
hope this help someone else :)
The how-to on Super Tech Guy's page (http://www.supertechguy.com/help/security/freeradius-google-auth) has a typo.
DEFAULT Auth-Type := PAM
should be
DEFAULT Auth-Type = PAM
I don't know why he put a colon in there, but removing it fixed my issue.
This was after I made sure the server had the correct time (and timezone), which it didn't. So thanks for that suggestion too!

Resources