• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Scratch files in Android Studio not working

RhinoCan

Well-Known Member
I often got a real benefit from scrapbook pages in Eclipse so I did a bit of digging and found that scratch files are the equivalent in Android Studio. I found a short video that told me how to create them - see
- and tried creating a very simple one. Within a file named scratch.java, I created this code:
Java:
public class scratch {

    public static void main(String[] args) {

        System.out.println("Hello World");
    }
}

There are no errors of any kind indicated in the source code. Whenever I try to run it though, I get:
Code:
Error: Could not find or load main class scratch

Process finished with exit code 1

Any idea what I'm doing wrong? I'm guessing that I have to turn something on in Android Studio or install a plugin of some kind but I can't find any instructions telling you to do certain tasks before writing your first scratch file.

I upgraded to Android Studio 3.1.4 the other day. I'm running in Windows 10.
 
Looks like you forgot the import statement

Code:
import java.util.*;
 
Oops. That was a mistake in copying the code into the question; the import is actually there. If it were missing, I'd get a different error.
 
Back
Top Bottom