-3

I am new to java and I am currently trying to run a program for a class assignment and it compiles however, every time I run it I get this error "Error: Could not find or load main class sailboat.java" To make things worse I need to submit this in a different way from standard assignments logging onto the main server of my campus and transfer it from my directory to another yet every time I do it, it tells me it can't open the source file.

Would these two situations because by the same thing? Is this something caused by a mistake in my code, or is it something wrong with my Classpath?

here's the code I made, I used notepad++

import java.text.*;
import java.io.*;
import java.math.*;

public class sailboat {
    public static void main (String argv []) throws IOException {
        BufferedReader stdin =
                new BufferedReader (new InputStreamReader (System.in));
        String inputValue;


        //Tartan 34C Title
        System.out.println("Sailboat: Tartan 34C");
        //Tartan 34C inputs
            double LOA = Double.parseDouble("34.50");
            double LWL = Double.parseDouble("24.00");
            double beam = Double.parseDouble("10.20");
            double displace = Double.parseDouble("11200.00");
            double displace_Ton = Double.parseDouble("5.60");
            double sail_Area = Double.parseDouble("483.00");


            //Hull Speed Formula
            double hull_Speed = Math.sqrt(LWL) * 1.34; 
                System.out.println("Hull Speed:" + hull_Speed);


            //Displacement to Waterline Length Formula
            double displace_Lng =  displace_Ton / 0.01 * Math.pow(LWL, 3.0);
                System.out.println("Displacement to water lenght:" + displace_Lng);


            //Sail Area to Displacement Formula
            double sail_Area_Displace = sail_Area / Math.pow((displace / 64), 0.67);
                System.out.println("Sail Area to displacement:" + sail_Area_Displace);


            //Capsize Screening Index Formula
            double Cap_I = beam / Math.pow((displace / 64), 0.33);
                System.out.println("Capsize Screening Index:" + Cap_I);


            //Comfort Index Formula
            double Comf_I = displace / (0.7 * LWL + 0.3 * LOA) * 0.65 * Math.pow(beam, 1.33);
                System.out.println("Comfort Index:" + Comf_I + "\n");

any input would be helpful.

  • You are missing curly braces at the end. Common atleast use online IDE. This question doesn't help anyone. – Abhishek Anand Jan 31 '16 at 17:24
  • i worked on this one issues for 4 hours last night and that thread didn't help me at all, the answer here helped with at least one of my problems faster then i could find anything. i know it was a stupid question but I was running out of options – Cory Dianovich Jan 31 '16 at 17:35

2 Answers2

0

Ok, lets try this:

When you're using the Notepad++, Sublime Text, etc. you must compile it from the Command Line with this statements

In your path

javac nameOfTheClass.java
java nameOfTheClass

What I supossed you did is that you include in the last statement the .java extension, avoid this one.

Horacio Garza
  • 45
  • 2
  • 7
  • Yes it seems that was what was happining cus i was using cd $(CURRENT_DIRECTORY) javac $(FILE_NAME) java $(FILE_NAME) for my compile and running macro – Cory Dianovich Jan 31 '16 at 17:30
0

You're missing two }s at the end of your file. 1 to close public static void main(String argv []) and another to close public class sailboat. You can just put them at the bottom of the file. I'd suggest using an IDE such as Eclipse, which has a rather intelligent syntax scanner that would have alerted you to this mistake.

Pyrrhic
  • 65
  • 10
  • Additionally `import java.text.*;`, `import java.math.*;`, `BufferedReader stdin`, and `String inputValue` are unused. They may be used in other classes or something which we're not aware of however. – Pyrrhic Jan 31 '16 at 18:02