Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Why can't my Java code run????
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mar5000k




PostPosted: Sun Sep 23, 2012 1:37 pm   Post subject: Why can't my Java code run????

Hi, I need your help!
why do you think is wrong with my code below?



* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assan;


/**
*
* @author Assan
*/
public class Assan {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
String name;
String favcolor;
String email;
double salary;

TextIO.putln("Good afternoon!, This program will creat your profile ");
TextIO.putln("if you could answer a few questions");
TextIO.putln();

TextIO.put("what is your nname ");
name = TextIO.getln();
TextIO.putln("What's your email adress ");
email = TextIO.getln();
TextIO.putln("What's your Favourite color ");
favcolor = TextIO.getln();
TextIO.putln("what's your yearly salary ");
salary = TextIO.getlnDouble();

System.out.print(name + ", your email adress is "+ email +" Favorite color is ");
System.out.println("+ color" + "and yr salary is " + salary);



}
}

When I compiled it, below is the outcome.


ant -f C:\\Users\\Assan\\Documents\\NetBeansProjects\\assan clean jar
init:
deps-clean:
Updating property file: C:\Users\Assan\Documents\NetBeansProjects\assan\build\built-clean.properties
Deleting directory C:\Users\Assan\Documents\NetBeansProjects\assan\build
clean:
init:
deps-jar:
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build
Updating property file: C:\Users\Assan\Documents\NetBeansProjects\assan\build\built-jar.properties
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\classes
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\empty
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\generated-sources\ap-source-output
Compiling 3 source files to C:\Users\Assan\Documents\NetBeansProjects\assan\build\classes
C:\Users\Assan\Documents\NetBeansProjects\assan\src\assan\TextIO (1).java:46: error: class TextIO is public, should be declared in a file named TextIO.java
public class TextIO {
1 error
C:\Users\Assan\Documents\NetBeansProjects\assan\nbproject\build-impl.xml:915: The following error occurred while executing this line:
C:\Users\Assan\Documents\NetBeansProjects\assan\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

And when I insisted on running it, below is the output.


run:
Exception in thread "main" java.lang.ExceptionInInitializerError
at assan.Assan.main(Assan.java:24)
Caused by: java.lang.RuntimeException: Uncompilable source code - class TextIO is public, should be declared in a file named TextIO.java
at assan.TextIO.(TextIO (1).java:46)
... 1 more
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)

NB. I'm using netbeans7.2, and im using TextIo.java class which is not a built-in function of java library.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Sep 23, 2012 3:25 pm   Post subject: Re: Why can't my Java code run????

mar5000k @ Sun Sep 23, 2012 1:37 pm wrote:
ant -f C:\\Users\\Assan\\Documents\\NetBeansProjects\\assan clean jar
init:
deps-clean:
Updating property file: C:\Users\Assan\Documents\NetBeansProjects\assan\build\built-clean.properties
Deleting directory C:\Users\Assan\Documents\NetBeansProjects\assan\build
clean:
init:
deps-jar:
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build
Updating property file: C:\Users\Assan\Documents\NetBeansProjects\assan\build\built-jar.properties
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\classes
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\empty
Created dir: C:\Users\Assan\Documents\NetBeansProjects\assan\build\generated-sources\ap-source-output
Compiling 3 source files to C:\Users\Assan\Documents\NetBeansProjects\assan\build\classes
C:\Users\Assan\Documents\NetBeansProjects\assan\src\assan\TextIO (1).java:46: error: class TextIO is public, should be declared in a file named TextIO.java
public class TextIO {
1 error
C:\Users\Assan\Documents\NetBeansProjects\assan\nbproject\build-impl.xml:915: The following error occurred while executing this line:
C:\Users\Assan\Documents\NetBeansProjects\assan\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: