Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

basic java

Options
  • 14-11-2007 1:34pm
    #1
    Registered Users Posts: 500 ✭✭✭


    Folks,

    I have a sample application using java. I usually run it from within my eclipse ide. And it runs grand.

    Now i want to ship it as an executable for a basic user to click on. Or even run from dos.

    I cannot run it from dos
    it keeps giving me exception from thread main NoClassdeffounderror:

    I am using jre 1.5.
    What am i doing stupid?

    And how do you propose i run it as an application for a basic user? Applet?


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Can we see the code, and how you're trying to launch it from the prompt?

    By the looks of things, you're missing a required class.


  • Registered Users Posts: 500 ✭✭✭warrenaldo


    Lets assume its a helloworld output class. Now in eclipse it works perfect.

    from the prompt i type
    java helloworld.java
    java helloworld

    nothing works.

    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld

    Please help


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    I presume you navigate to the folder the helloworld class is in?

    java helloworld.java wouldn't work, because that is the source file and not the compiled class file.


  • Registered Users Posts: 3,548 ✭✭✭Draupnir


    Do you need to do

    javac HelloWorld.java
    java HelloWorld

    ??

    I havent done java since college.


  • Registered Users Posts: 500 ✭✭✭warrenaldo


    yes im in the correct folder. its driving me mad.


  • Advertisement
  • Registered Users Posts: 378 ✭✭sicruise


    Eclipse by default afaik adds a package to your project where all of your classes are held.

    You will need to run it doing something like

    java package.class

    where package is the name of your package and class the name of your class... and do it from the folder that contains the package not the class itself.

    edit: Make sure the package folder is in your classpath!


  • Registered Users Posts: 378 ✭✭sicruise


    Here's something useful for you to read...

    http://www.jarticles.com/package/package_eng.html


  • Registered Users Posts: 500 ✭✭✭warrenaldo


    thank you :-)


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    sicruise wrote: »
    Eclipse by default afaik adds a package to your project where all of your classes are held.

    Naa it doesn't. It will create a src folder but it is independant of the package.

    Easiest thing to do is export the java file as a JAR then specify the jar as a self-executing then point to your class.

    After that just double click the jar file.


  • Registered Users Posts: 500 ✭✭✭warrenaldo


    ok moving onto problem number 2.

    i want a way for the user to ba able to interact with the program. simple input. should i create an applet? if i do - can i make it executable?


  • Advertisement
  • Registered Users Posts: 527 ✭✭✭Sean^DCT4


    you can create a JAR file which is "executable" providing the user has the JRE installed.
    Use Eclipse to do the GUI and as a previous poster said, Eclipse will generate a JAR file for you.

    Seany


Advertisement