CanadianLoser
Meow :3 :3
+1,148|6753
i have to hand in a java project (very simple porject) in less than an hour and i just typed my first script evar!

Problem: can't compile it i'm using textpad but also have notepad if that makes it easier. 

Question: If you can help me compile it I would much appreciate it, otherwise if you could tell me if the below code would work and what should be changed if it doesn't I would love you very much. 

inb4noobprogram.  does not need to be short or complex or anything. just has to display:

Let's Program (x5)
And live it up
Let's Program (x5)
I gotta feeling that tonight’s gonna be a good night
That tonight’s gonna be a good night
That tonight’s gonna be a good good night
A feeling
That tonight’s gonna be a good night (x2)
That tonight’s gonna be a good good night

Code:

public class IGottaFeeling
{
    public static void main (String [] args)
    {
        int max = 10;
        int numberOfTimes = 0;

        while (numberOfTimes <= max)
        {
            System.out.println ("Let's Program");

            if (numberOfTimes == 4)
            {
                System.out.println ("And live it up");
            }
            numberOfTimes = numberOfTimes + 1;
        }
        {
            System.out.println (" I gotta feeling that tonight’s gonna be a good night");
           System.out.println ("That tonight’s gonna be a good night");
            System.out.println ("That tonight’s gonna be a good good night");    
             System.out.println ("A feeling");
              System.out.println ("That tonight’s gonna be a good night");
               System.out.println ("That tonight’s gonna be a good night");
                System.out.println ("That tonight’s gonna be a good good night");
            }
         
    }
}
thanks! <3
jsnipy
...
+3,277|6768|...

>C:\Sun\SDK\jdk\bin\javac.exe C:\IGottaFeeling.java

>C:\Sun\SDK\jdk\bin\java.exe C:\IGottaFeeling.class
Exception in thread "main" java.lang.NoClassDefFoundError: C:\IGottaFeeling/clas
s
Caused by: java.lang.ClassNotFoundException: C:\IGottaFeeling.class
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: C:\IGottaFeeling.class.  Program will exit.


I did install SDK, but just running java C:\yousourcefile.java will give you the error message (in other words you did not need javac, that jsut makes the class file). In your case "Could not find the main class: C:\IGottaFeeling.class.  Program will exit."
Surgeons
U shud proabbly f off u fat prik
+3,097|6735|Gogledd Cymru

It works, make sure to save it as "IGottaFeeling.java" though then open a command prompt, navigate to the directory it's in and type "javac IGottaFeeling.java" then to run type "java IGottaFeeling"
CanadianLoser
Meow :3 :3
+1,148|6753

The Sheriff wrote:

It works, make sure to save it as "IGottaFeeling.java" though then open a command prompt, navigate to the directory it's in and type "javac IGottaFeeling.java" then to run type "java IGottaFeeling"
javac is not recognized as an internal or external command, operable program or batch fie
jsnipy
...
+3,277|6768|...

change your main declaration: public static void main(String args[])

CanadianLoser wrote:

The Sheriff wrote:

It works, make sure to save it as "IGottaFeeling.java" though then open a command prompt, navigate to the directory it's in and type "javac IGottaFeeling.java" then to run type "java IGottaFeeling"
javac is not recognized as an internal or external command, operable program or batch fie
once you install JDK the path to it will be (assuming you take defaults) C:\Sun\SDK\jdk\bin\javac.exe

Last edited by jsnipy (2009-09-22 17:57:26)

Board footer

Privacy Policy - © 2024 Jeff Minard