java + sun one studio


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: java + sun one studio

  1. #1
    Join Date
    Nov 2004
    Posts
    3

    java + sun one studio

    I'm new to java, or rather returning after an extended hiatus. I am currently using the trial version of sun one studio to re-aquaint myself with java.

    At present I am running into a consistant line of errors which i believe have to do with the ide. take the following code example.

    PHP Code:
    import javax.swing.JOptionPane;
    /**
     *
     * @author  Owner
     */
    public class NameDialog {
        
        public static 
    void main (String args[])
        {
            
    String myName JOptionPane.showInputDialog("test");
            
            
    String message String.format("welcome, %s, to Java"myName);
            
            
    JOptionPane.showMessageDialog(nullmessage);
        }
        

    now this should work according to the java online reference manual as well as the book i have. yet I am getting the following error message.

    location: class java.lang.String
    String message = String.format("welcome, %s, to Java", myName);
    I am left with the conclusion that it may have something to do with how I am setting up my file structure.

    Any feedback is appreciated.

    best,

    ed.
    "Ignorance can be cured, pride is deadly" - unknown

  2. #2
    Join Date
    Sep 2004
    Posts
    223
    coudl you show more of the error message, it doesnt look like that is all that it says, usually it tells you the "type" of error. Not just the location of it.

    Why dont you try to simplify your code down some more, just do a simple:

    Code:
    import javax.swing.JOptionPane; 
    /** 
    * 
    * @author  Owner 
    */ 
    public class HelloWorld { 
         
        public static void main (String args[]) 
        { 
            System.out.println("Hello World");
        } 
         
    }
    then you cant go wrong.
    If that compiles then it could very well be your code
    A kram a day keeps the doctor......guessing

  3. #3
    Join Date
    Nov 2004
    Posts
    3

    full error message

    THe Code error I get is as follows.


    nameDialog2.java [9:1] cannot resolve symbol
    symbol : method format (java.lang.String,java.lang.String)
    location: class java.lang.String
    String message = String.format("welcome, %s, to Java", myName);
    ^
    1 error
    Errors compiling nameDialog2.

    The hellow world program works fine. Tried that first, now in trying to use what should be a straight forward showMessageDialog function idoes not want to work

    ed.
    "Ignorance can be cured, pride is deadly" - unknown

  4. #4
    Join Date
    Sep 2004
    Posts
    150
    I think you're exactly right that it might be something with the IDE.

    String.format is new with 1.5, apparently. The IDE's might not be ready for some of the syntax.

    For example, I was trying to use Eclipse 3.0.1 to build your code and got an error on the exact same line. The error was telling me that Java was expecting (String, Object[])...

    not (String, String).

    Now the Java 1.5 can take unlimited parameters now with object arrays. For example, you should be able to do (String, String, String, int, String, double, ...);

    and Java should stick these parameters in an Object [] array.

    But the IDE is expecting "literally" an Object[] array, because apparently it doesn't understand this new concept. And it isn't happy with anything else.

    I tried it using Netbeans 4.0 beta and it built just fine.

    Definitely an IDE that does not understand that Object[] as a parameter means basically limitless parameters.

    I don't know what you should do though. I imagine this is something they would want to know about.

  5. #5
    Join Date
    Nov 2004
    Posts
    3

    thanks

    thanks for lletting me know. had another friend check it out as well. I guess I will just use the old "+" con concatenate.

    Just frustrationg to try and learning and be thrown stumbling blocks in the begining.

    ed
    "Ignorance can be cured, pride is deadly" - unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center