I have a raspberry pi running lubuntu 16.04. I want to connect to it directly via an ethernet cable. I can connect to it via a vnc server (over the Internet) but that's not preferred as i need to connect a dongle to it. Please tell me how to set a static ip address on both machines and enable a direct communication. Most answers I saw are for raspbian, not lubuntu.
You don't need to do anything! Just connect with an Ethernet cable.
Most Ubuntu distos support Zero-conf and you should be able to connect using a Link-local address so you can use
raspberrypi.local (or hostname.local if using a different hostname) instead of IP address.
If you really want to use a static IP address most Ubuntu distos let you do this from the networking symbol on the GUI.
How to set up networking/WiFi which discusses these concepts on Raspbian.
Try "lubuntu set static ip" in your favorite search service. There will be enough answers so that you can find one to suit your environment.
The two IP addresses you choose must be different, of course, and in the same subnet. You should use only private addresses for something like this. Try 192.168.139.1 and 192.168.139.2 with a subnet mask of 255.255.255.0. Addresses in the 192.168.x.x block are reserved for private IP networks, I pulled 139 right out of my ear. The one and two are host numbers. The subnet mask above means that the first three octets of the IP address are the network and the last octet is the host.
The part that might be more troublesome is that you may need an Ethernet crossover cable. Probably not, though, because most modern Ethernet interfaces are smart enough to figure this out. (See "automatic crossover" in the Wikipedia article in the link.) If you have, or can borrow, an Ethernet hub or switch, first set static IPs on both and connect both devices to the switch. When they're communicating successfully, take the switch out and connect them directly. If everything still works, you're done! If not, you will continue to need that hub or switch, or get a crossover cable.