So trying to get back into Java programming, I thought I would start a simple program writing to a SQLITE database. Initially this was a Maven project, but I had problems so got even more basic and just wanted to do a simple single class program. Well, still having trouble right off the bat.
The program and sqlite jdbc driver are located in the same folder. If anybody has some idea on how I can run this successfully, I would appreciate input. It's probably a really stupid mistake I'm sure..
First, I compiled the program using the command:
Second, I attempted to run the program, including the driver in the classpath:
For comparison, I created the same program using IntelliJ instead and was able to run the program through the IDE. The console showed the following command which looks the same in format as mine above:
It looks like you are using the wrong entry separator in your classpath declaration. If you are using Bash or another Unix command line interface, you must use colons instead of semi-colons to separate the classpath entries.
Backslashes are perilous. as they have a "magic" meaning in Unix-like systems, and Java is very Unix-like, even when running under Windows. You can usually use forward slashes in Java and be safer. For example:
I think you might find it works better on the command line as well:
Also, to expand on Stephan's explanation, the Unix shells use ";" (semi-colon) to allow one to stack multiple commands on a single input line, where each ";" serves the same function as an end-of-line (RETURN). Meaining that in the wrong context, the shell will be given an incomplete "java" command followed by a command apparently named "./sqlite-jdbc-126.96.36.199.jar".
But here again, Windows and Unix (including Linux) are captive to their command shell traditions, so for the most part, where you'd use a colon in Unix you'd use a semi-colon in Windows and vice versa. A notable exception being in drive letters, where C: is still C:
What can get really confusing is if you're running under Linux emulation such as cygwin, since the Unix (cygwin) command windows would obey Unix rules, but the windows ("CMD.COM") windows would object Windows rules. Usually.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
Thank you both for your responses, it got me looking at this more closely. I'm working in windows, but also I was using the terminal through VSCode... and it was a PowerShell Terminal not a CMD. Once I changed the terminal type to CMD it worked perfectly.
I also used your advice and changed the URL to forward slashes instead of the double backslash.