-2

I'm working on a website for a school project and I'm using html and JavaScript to write it. I wrote a program in java that I'm going to add to the website I'm a little confused about how to implement it into the website, do I just copy paste it into the script of the html or am I missing something

<script type ="text/javascript">


</script>

would I just copy paste the java code in-between there?

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class SearchForWords {

    public static void main(String[] args) {


        String filename = "input3.c";
        try {
            Scanner sc = new Scanner(new File(filename));
            int lineCount = 1;
            while(sc.hasNextLine()) {
                String line = sc.nextLine();
                if(line.contains("gets")) {
                    System.out.println("Use fgets() instead of gets() : Found in line " + lineCount);
       
                lineCount++;
            }

            sc.close();
        } catch (FileNotFoundException e) {
            System.out.println("File not found");
        }

    }

}
Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

1 Answers1

0

No, copy pasting the code will not work. The reason was already given: java very much is not javascript, they are different languages and have nothing to do with each other.

If we are talking about how to put javascript code into HTML you have two options: copy paste it in or import it using the src of a script tag: Where should I put <script> tags in HTML markup?

luk2302
  • 55,258
  • 23
  • 97
  • 137