Question: I keep getting a Could not find or load main class error in my java program heres my code: import java.util.*; import java.io.*; public class

I keep getting a Could not find or load main class error in my java program

heres my code:

import java.util.*; import java.io.*; public class Lab4 {

public static void main(String[] args) throws Exception { if (args.length <= 0) { System.out.println("No text file was entered on command line"); System.exit(0); }

BufferedReader infile = new BufferedReader(new FileReader(args[0])); ArrayList wordList = new ArrayList(); String word; while ((word = infile.readLine()) != null) { wordList.add(word); } infile.close(); Collections.sort(wordList); for (String word2 : wordList) { System.out.println(word2); canonical(word2); } }

static String canonical(String word) { char[] letters = word.toCharArray(); Arrays.sort(letters); return new String(letters); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!