Results 1 to 13 of 13
  1. #1
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default New To Java/How To Create a Build for Test

    Hello.

    I am a Microsoft developer, but am working on a proof of concept that is a Java form.

    I am trying to figure out how I can compile/build what I have so far and test it on a development environment.

    I am using Eclipse and attempted to build a runable jar, however I received this error:

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: 
    C:\Documents and Settings\dexterdr\Desktop\SASMacroTest/jar
    Caused by: java.lang.ClassNotFoundException: C:\Documents and Settings\dexterdr\Desktop\SASMacroTest.jar
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: C:\Documents and Settings\dexterdr\Desktop\SASMacroTest.jar.  
    Program will exit.
    I've seen that some people say the best way to create a Java distribution is to use Ant or Maven that Eclipse isn't geared towards this.

    Since I come from a Microsoft background this is all very new to me..

    Any suggestions?

    Thanks in advance..

    doug

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: New To Java/How To Create a Build for Test

    A simple jar can be created using an IDE such as eclipse. Is the exception above show when you try to execute the jar file? I think you need to define the main-class in the jar's manifest file. See more details here: Setting an Application's Entry Point (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: New To Java/How To Create a Build for Test

    What is the command line you used to get the error? It looks like you specified the path to a jar file where the name of the class should go. Read the doc for the syntax for the jar file.
    If the jar file is executable (has a properly constructed manifest file), you needed to use the -jar option before the path to the jar file.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    I'm using this on the remote machine:
    java -jar "c:\path\myjar.jar"

    Also, this runs on my development machine with no errors.

    thanks
    Last edited by drdexter33; 03-26-2013 at 03:19 PM.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: New To Java/How To Create a Build for Test

    Post the content of the manifest.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    Sure:

    Manifest-Version: 1.0
    Class-Path: . SASMacroTest_lib/zip4j_1.3.1.jar SASMacroTest_lib/sas.la
    uncher.jar
    Main-Class: UtilityForm


    Thanks.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: New To Java/How To Create a Build for Test

    Where is the reference to the class named in the error message:
    Could not find the main class: C:\Documents and Settings\dexterdr\Desktop\SASMacroTest.jar.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    Not sure I understand the question, but I think you're asking where is the SASMacroTest.class?

    If so, I just named the runable jar SASMacroTest.jar, but there is no SASMacroTest.class.

    Here's an updated error from running the jar:


    C:\>java -jar "C:\Documents and Settings\dexterdr\Desktop\SASMacroTest.jar" <--this is the command line


    and the results:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: UtilityForm :
    Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: UtilityForm. Program will exit.

    It looks like it's looking for UtilityForm.class..but I viewed the .jar file and it is there:

    New To Java/How To Create a Build for Test-class.gif
    Last edited by drdexter33; 03-26-2013 at 04:03 PM.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: New To Java/How To Create a Build for Test

    What do you get from "> java -version" ?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: New To Java/How To Create a Build for Test

    That error is because the version of java being used is OLDER than the version of javac that created the class file (probably 1.7).


    Here's a way to get the error message you posted:
    Java Code:
    D:\JavaDevelopment\Testing\ForumQuestions8>java c:\temp\SomeJarFile.jar
    Error: Could not find or load main class c:\temp\SomeJarFile.jar
    
    D:\JavaDevelopment\Testing\ForumQuestions8>
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    ----------------------------------------------
    TEST MACHINE:
    ----------------------------------------------
    C:\>java -version > u:\version.txt
    java version "1.6.0_16"
    Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
    Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)

    ----------------------------------------------
    DEV MACHINE:
    ----------------------------------------------
    C:\Users\dexterdr>java -version
    java version "1.7.0_05"
    Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

  12. #12
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    How can i fix that?

  13. #13
    drdexter33 is offline Member
    Join Date
    Mar 2013
    Posts
    9
    Rep Power
    0

    Default Re: New To Java/How To Create a Build for Test

    I think I got it to work by changing the JRE library in Eclipse to 1.6.

    Thanks.

    Doug

Similar Threads

  1. Replies: 0
    Last Post: 11-25-2011, 02:25 PM
  2. Build a website using java or php?
    By i4ani in forum Networking
    Replies: 0
    Last Post: 10-28-2011, 09:53 PM
  3. Replies: 1
    Last Post: 08-04-2010, 04:24 PM
  4. [Montreal] Recruiting Build and Test Automation Architect
    By montreal.hr in forum Jobs Offered
    Replies: 0
    Last Post: 08-30-2008, 09:12 PM
  5. Replies: 0
    Last Post: 04-05-2008, 01:38 AM

Posting Permissions

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