I seem to be having an issue with getting my Java program to run in the web browser using the <applet>
tag.
Here's my code for importing the java .class:
<applet code="Userid.class"width="740" height="400"></applet>
For some reason, I keep getting an error that says "NoClassDefFoundError Userid (wrong name: userid/Userid)"
The Java program itself is not graphical if that is one of the issues. Just in case, here is my source code for the Java application:
package userid;
import java.util.Scanner;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.Writer;
import java.io.File;
import java.io.IOException;
public class Userid {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
String userid = in.nextLine();
try{
File users = new File(userid+".txt");
BufferedWriter output;
output = new BufferedWriter(new FileWriter(users, true));
output.newLine();
output.append(userid);
output.close();
new File(userid).mkdirs();
System.out.println("> New user " +userid+ " has been added.");
System.out.println("> Please use this name everytime you use Oswald.");
}
catch (IOException e) {
}
}
}
The program runs just fine in NetBeans and the .class is in the same exact directory as the HTML file. Am I perhaps doing something wrong here? Thanks!