Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Error JOption

  1. #1
    Junior Member
    Join Date
    Aug 2024
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Error JOption

    Hello! I am a beginner, along with introducing myself, I have the following problem in my basic java code. I think everything is fine, but for some reason the machine gives me an error...

     
     
    package com.mycompany.holamundo;
     
    import javax.swing.JOptionPane;
     
     
    /**
     */public class Holamundo {
     
       public static void main (String [] args){
     
           String cadena;
           int entero;
           char letra;
           double decimal;
     
           cadena = JOptionPane.showInputDialog("Digite cadena");
           entero = Integer.parseInt(JOptionPane.showInputDialog("Digite entero"));
           letra =  JOptionPane.showInputDialog("Digite caracter").charAt(0);
           decimal = Double.parseDouble(JOptionPane.showInputDialog("Digite decimal"));
     
         JoptionPane.showMessageDialog(null,"La cadena es"+cadena);
         JoptionPane.showMessageDialog(null,"La cadena es"+entero);
         JoptionPane.showMessageDialog(null,"El numero es"+letra);
         JoptionPane.showMessageDialog(null,"El decimal es"+decimal);
     
       }
      }


    Error message:



    ----------------------< com.mycompany:Holamundo >-----------------------
    Building Holamundo 1.0-SNAPSHOT
    from pom.xml
    --------------------------------[ jar ]---------------------------------

    --- resources:3.3.1:resources (default-resources) @ Holamundo ---
    skip non existing resourceDirectory C:\Users\danie\OneDrive\Documents\NetBeansProjects \Holamundo\src\main\resources

    --- compiler:3.11.0:compile (default-compile) @ Holamundo ---
    Changes detected - recompiling the module! :source
    Compiling 3 source files with javac [debug target 22] to target\classes

    --- exec:3.1.0:exec (default-cli) @ Holamundo ---
    Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
    at com.mycompany.holamundo.JoptionPane.showMessageDia log(JoptionPane.java:14)
    at com.mycompany.holamundo.Holamundo.main(Holamundo.j ava:24)
    Command execution failed.
    org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInt ernal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:1000)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:947)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:471)
    at org.apache.maven.plugin.DefaultBuildPluginManager. executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.d oExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.d oExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.e xecute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.e xecute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.a ccess$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1 .run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrat egy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.e xecute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModul eBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModul eBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.single threaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStart er.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.in voke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher. launchEnhanced (Launcher.java:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher. launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher. mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher. main (Launcher.java:348)
    ------------------------------------------------------------------------
    BUILD FAILURE
    ------------------------------------------------------------------------
    Total time: 16.822 s
    Finished at: 2024-08-03T10:23:17-04:00
    ------------------------------------------------------------------------
    Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:exec (default-cli) on project Holamundo: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

    To see the full stack trace of the errors, re-run Maven with the -e switch.
    Re-run Maven using the -X switch to enable full debug logging.

    For more information about the errors and possible solutions, please read the following articles:
    [Help 1] http://cwiki.apache.org/confluence/d...utionException


    If anyone can help me, thank you!
    Last edited by bach; August 3rd, 2024 at 09:29 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Error JOption

    the machine gives me an error..
    Please copy the full text of the error message and paste it here so we can see what the error is.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2024
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Error JOption

    Quote Originally Posted by Norm View Post
    Please copy the full text of the error message and paste it here so we can see what the error is.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    Understood. I put it in the initial post

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Error JOption

    That is a lot of error messages for a simple misspelling of a name. I have never seen an error trace like that.
    I do not see anything in the trace that I recognize.
    What IDE are you using?

    Here are the error messages I get when I compile the source:
    Running: C:\Program Files\Java\jdk1.8.0_60\bin\javac.exe -cp . -Xlint -Xdiags:verbose Holamundo.java

    Holamundo.java:20: error: cannot find symbol
    JoptionPane.showMessageDialog(null,"La cadena es"+cadena);
    ^
    symbol: variable JoptionPane
    location: class Holamundo
    Holamundo.java:21: error: cannot find symbol
    JoptionPane.showMessageDialog(null,"La cadena es"+entero);
    ^
    symbol: variable JoptionPane
    location: class Holamundo
    Holamundo.java:22: error: cannot find symbol
    JoptionPane.showMessageDialog(null,"El numero es"+letra);
    ^
    symbol: variable JoptionPane
    location: class Holamundo
    Holamundo.java:23: error: cannot find symbol
    JoptionPane.showMessageDialog(null,"El decimal es"+decimal);
    ^
    symbol: variable JoptionPane
    location: class Holamundo
    4 errors

    4 error(s)
    The above error message says: cannot find symbol variable JoptionPane
    Look at the spelling of that variable: it use an o vs an O
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    bach (August 3rd, 2024)

  6. #5
    Junior Member
    Join Date
    Aug 2024
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Error JOption

    Quote Originally Posted by Norm View Post
    That is a lot of error messages for a simple misspelling of a name. I have never seen an error trace like that.
    I do not see anything in the trace that I recognize.
    What IDE are you using?

    Here are the error messages I get when I compile the source:
    The above error message says: cannot find symbol variable JoptionPane
    Look at the spelling of that variable: it use an o vs an O
    I am using netbeans 22 as an IDE.

    By changing the O to the o it doesn't even let me type the variables (with O it reads them but marks an error at the output). This is the new error:




    ----------------------< com.mycompany:Holamundo >-----------------------
    Building Holamundo 1.0-SNAPSHOT
    from pom.xml
    --------------------------------[ jar ]---------------------------------

    --- resources:3.3.1:resources (default-resources) @ Holamundo ---
    skip non existing resourceDirectory C:\Users\danie\OneDrive\Documents\NetBeansProjects \Holamundo\src\main\resources

    --- compiler:3.11.0:compile (default-compile) @ Holamundo ---
    Changes detected - recompiling the module! :source
    Compiling 4 source files with javac [debug target 22] to target\classes
    -------------------------------------------------------------
    COMPILATION ERROR :
    -------------------------------------------------------------
    javax/swing/JoptionPane.java:[5,1] package exists in another module: java.desktop
    1 error
    -------------------------------------------------------------
    ------------------------------------------------------------------------
    BUILD FAILURE
    ------------------------------------------------------------------------
    Total time: 1.330 s
    Finished at: 2024-08-03T12:17:11-04:00
    ------------------------------------------------------------------------
    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project Holamundo: Compilation failure
    javax/swing/JoptionPane.java:[5,1] package exists in another module: java.desktop

    -> [Help 1]

    To see the full stack trace of the errors, re-run Maven with the -e switch.
    Re-run Maven using the -X switch to enable full debug logging.

    For more information about the errors and possible solutions, please read the following articles:
    [Help 1] http://cwiki.apache.org/confluence/d...ilureException

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Error JOption

    I do not know anything about your IDE. It looks like there is something wrong with the IDE's setup.
    Sorry, I can not help with the setup of the Netbeans IDE.
    Why are you using the Netbeans IDE?
    Has anything else worked with the IDE?
    Did the IDE ever work or has the problem been only with this source file?
    If you don't understand my answer, don't ignore it, ask a question.

  8. The Following User Says Thank You to Norm For This Useful Post:

    bach (August 3rd, 2024)

  9. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Error JOption

    Here is a thread that may be of interest: https://www.coderanch.com/t/781073/j...Java-IDE-start

    I agree that a beginner should learn java by using the command-line initially and worry about using an IDE later once he has a basic understanding of how java works. IDEs (as you are showing) can be difficult to setup.
    I personally do not use an IDE for java. I have an enhanced editor with tailorable command-line commands. I do use an IDE (Eclipse) for android.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #8
    Junior Member
    Join Date
    Aug 2024
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Error JOption

    It looks like you're working on a basic Java program to take user input and display it using JOptionPane. You've done a great job so far, but there are a couple of small issues in your code that need to be corrected.

    Here's your corrected code:
    package com.mycompany.holamundo;

    import javax.swing.JOptionPane;

    public class Holamundo {

    public static void main(String[] args) {

    String cadena;
    int entero;
    char letra;
    double decimal;

    cadena = JOptionPane.showInputDialog("Digite cadena");
    entero = Integer.parseInt(JOptionPane.showInputDialog("Digi te entero"));
    letra = JOptionPane.showInputDialog("Digite caracter").charAt(0);
    decimal = Double.parseDouble(JOptionPane.showInputDialog("Di gite decimal"));

    JOptionPane.showMessageDialog(null, "La cadena es " + cadena);
    JOptionPane.showMessageDialog(null, "El entero es " + entero);
    JOptionPane.showMessageDialog(null, "El caracter es " + letra);
    JOptionPane.showMessageDialog(null, "El decimal es " + decimal);
    }
    }

  11. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Error JOption

    couple of small issues in your code that need to be corrected.
    Can you explain what those issues are to help the OP understand?
    Just giving the OP code that can be copied and pasted will not help him learn.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. JOption
    By Ash4k in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 25th, 2019, 03:06 AM
  2. Calculator Using JOption
    By Jrams in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 19th, 2018, 10:31 AM
  3. JOption help
    By Ryn440 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 27th, 2014, 12:45 PM
  4. Java joption
    By darking123 in forum Object Oriented Programming
    Replies: 9
    Last Post: February 5th, 2013, 10:51 AM
  5. JOption Pane help
    By dallas1125 in forum AWT / Java Swing
    Replies: 5
    Last Post: November 18th, 2009, 05:08 PM