The Artima Developer Community
Sponsored Link

Java Answers Forum
Stuck in the first java program

1 reply on 1 page. Most recent reply: Oct 22, 2012 3:56 PM by Kishori Sharan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Darren Ang

Posts: 1
Nickname: darren5559
Registered: Aug, 2012

Stuck in the first java program Posted: Aug 5, 2012 5:43 AM
Reply to this message Reply
Advertisement
hi,

i am a newbie in java programming. given suggestion by most user, i download a pdf file of Bruce Eckel's "Thinking in Java 4th Edition", but i stuck in the first program, and i tried to surf net to find solution to solve it, but no luck, i believe it is a small problem, hoping any expert can help me.

first, i am using netbean ide 7.1 with jdk1.7.0_02, according to url http://www.mindviewinc.com/TIJ4/CodeInstructions.html, i install the TIJ4 source code in the directory D:\data\project\java\TIJ4-code. i also change the environment CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;D:\data\project\java\TIJ4-code;. on the other hand, i create a new project named shortform.java, and the source code is listed as below :-

// start
package shortform;
// D:\data\project\java\TIJ4-code
import static net.mindview.util.Print.print;

public class Shortform {
public static void main(String[] args) {
print("This is a test");
}
}
// end

to run the program, i need to add a D:\data\project\java\TIJ4-code folder into shortform->project properties->libraries->Compile section, according to the example in the book, the sample use "import static net.mindview.util.Print.*;" statement, but the netbean compilier show a error on the editor, the error is "Import section does not correspond to the specified code style rules.", so i change to "import static net.mindview.util.Print.print;", then the error is gone. when i click the "test project (shortform)" (alt-F6), the error is show as below :-

// start -------------------------------------------------
init:
Deleting: D:\data\project\java\test\shortform\build\built-jar.properties
deps-jar:
Updati ng property file: D:\data\project\java\test\shortform\build\built-jar.properties
init:
deps-clean :
Updating property file: D:\data\project\java\test\shortform\build\built-clean.properties
Deleting directory D:\data\project\java\test\shortform\build
clean:
Created dir: D:\data\project\java\test\shortform\build\classes
Created dir: D:\data\project\java\test\shortform\build\empty
Created dir: D:\data\project\java\test\shortform\build\generated-sources\ap-source-output
Co mpiling 1 source file to D:\data\project\java\test\shortform\build\classes
D:\data\project\java\test\sho rtform\src\shortform\Shortform.java:8: error: package net.mindview.util does not exist
import static net.mindview.util.Print.print;
D:\data\project\java\test\shortform\src\shortfor m\Shortform.java:8: error: static import only from classes and interfaces
import static net.mindview.util.Print.print;
D:\data\project\java\test\shortform\src\shortfor m\Shortform.java:26: error: cannot find symbol
print("This is a test");
symbol: method print(String)
location: class Shortform
3 errors
D:\data\project\java\test\shortform\nbproject\build-impl.xml:605: The following error occurred while executing this line:
D:\data\project\java\test\shortform\nbproject\build-impl.xml:246: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
// end ----------------------------------------------------

anyone please help me if u know the problem, thanks


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: Stuck in the first java program Posted: Oct 22, 2012 3:56 PM
Reply to this message Reply
Try reading Chapter 2 of my book Harnessing Java 7 Volume 1. This chapter is designed for beginners. You can read it using the following link.

http://books.google.com/books?id=SSaPXEH-mQUC&printsec=frontcover&dq=inauthor:%22Kishori+Sharan%22&source=bl&ots=XViFmM5daq&sig=JKLGSQKgF9stTZb6dSp3i_aGvi8&hl=en&sa=X&ei=3aOFUKWUPPS80QH6kIH4Dw&ved=0CC8Q6AEwAA#v=onepage&q&f=true

Flat View: This topic has 1 reply on 1 page
Topic: Help me please for homework Previous Topic   Next Topic Topic: ClassLoader's reference in method area


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us