Results 1 to 9 of 9

Thread: Running Java App Issue

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Running Java App Issue

    I needed to make a basic timer at work that needed to be used on Windows and OS X machines so I thought Java would be my best bet. Now I have experience in C++ and C# but absolutely non in Java.

    I downloaded and installed NetBeans IDE 4.1 and the 1.5.0 Java Runtime Environment. I created the program and it seems to work good. It created a .Jar file.

    When I try running it on any other system other than my own, it gives me an error saying it was unable to find the main class but I have it specified in my project.

    I even uninstalled everything on my computer, reinstalled NetBeans IDE with 1.4.2 instead (thought maybe the previous version was too new or something) with the same error.

    How do I fix this? I've never used Java before and I just kind of went with it. What did I do wrong?

    It's a swing application, btw and the JForm is the main class (I tried creating a main class just by itself but it wouldn't let me select it as the main class).

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Running Java App Issue

    The runtime probably can't find the class to execute. You said you have it specified in your project but i don't know if you are talking about your code or the IDE classpath settings.

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Running Java App Issue

    Quote Originally Posted by Dilenger4
    The runtime probably can't find the class to execute. You said you have it specified in your project but i don't know if you are talking about your code or the IDE classpath settings.
    With netBeans, when I go into the project's properties, there is an option for main class and I have it set.

    Not sure how to set IDE classpath settings or how to set it in code.

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Running Java App Issue

    Btw, when I try to run it with java web start I get the following error:
    Code:
    An error occurred while launching/running the application.
    
    Category: Launch File Error
    
    The following required field is missing from the launch file: <jnlp>
    Not sure if I am supposed to launch it with javaws.exe or not but maybe the error can help someone help me.

    Launching it with javaw.exe gives me the missing main class error and launching it with java.exe just plain doesn't work (though I am not suprised; I don't know much of anything about java. heh)

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Running Java App Issue

    I am pretty sure that you have to set the path to where your .class files reside. So the JVM knows where to grab them to execute. I really dont use IDE's too much. Pretty much code everyting in Edit Plus so i couldn't tell you exactly where to go within Net Beans.

  6. #6

  7. #7

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Running Java App Issue

    Quote Originally Posted by Dilenger4
    I am pretty sure that you have to set the path to where your .class files reside. So the JVM knows where to grab them to execute. I really dont use IDE's too much. Pretty much code everyting in Edit Plus so i couldn't tell you exactly where to go within Net Beans.
    I think you're right. In the IDE, if I right click on the package it'll show me the classpath but won't allow me to change it and when I try to add or change it as per some instructions I found, it doesn't work right.

    How can I set it up to just check the current directory for the class? Also, how would I compile the java project in command line? I'm used to gcc so it's weird letting an IDE do it for me anyway

    EDIT: Didn't see your reply. Thanks. I'll look into it

  8. #8
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Re: Running Java App Issue

    Command line from DOS. Compile --> C:\jdk1.5.0_03\bin> javac C:\prog Run --> C:\jdk1.5.0_03\bin> java -classpath C:\; prog I usally don't have my CLASSPATH set so specify the -classpath when i run.

  9. #9

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Running Java App Issue

    Quote Originally Posted by Dilenger4
    Command line from DOS. Compile --> C:\jdk1.5.0_03\bin> javac C:\prog Run --> C:\jdk1.5.0_03\bin> java -classpath C:\; prog I usally don't have my CLASSPATH set so specify the -classpath when i run.
    Since the jar file contains the class, shouldn't it be easy to set it so the Jar file is it's own classpath? I don't see why the classpath has to be specific instead of relative.

    Maybe I need a java book.

    I used a program called JSmooth which made my jar file into an exe and that works on multiple computers. I just need to figure out how to get OS X to work with it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width