I got a new air compressor that says 240 volt only but it only has a black and white wire please help.
Get some red electrical tape and wrap it around the white wire, this will make the wiring more obvious to you. It is not properly color-coded because they are using common off-the-shelf 3-wire cordage, which is manufactured as black/white/green. It's legal to omit the marking on machinery, but it's required in wiring that's part of your house (often omitted there too).
You will need 240V electrical service. If you connect it via cord and plug, you will need a NEMA 6 plug and a NEMA 6 receptacle. You can also use a NEMA 14 plug and receptacle; in that case you will not hook up neutral on the plug.
If you are doing brand-new wiring for this, it may be best to use /3 cable and bring along a neutral in the wiring to the outlet point. You would not use the neutral, but it would be installed and ready for use for some future application.
Each leg is 120 Volt. There is no common leg.