+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Jar application, what is the classpath?

  1. #1
    jonasdb is offline x10Hosting Member jonasdb is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    19

    Exclamation Jar application, what is the classpath?

    Hello guys,

    I've made a little thingy in java and jarred it, now to display it on my webpage to what directory should i upload it and what would be the classpath (codebase/archive) ?

    this is what i have:

    Code:
    <html> 
    <head> 
    <title>My Applet Page</html> 
    </head> 
     
    <body> 
    <applet code="Chat.class" archive="http://AAA.x10hosting.com/app.jar" width="600px" height="450px"> 
    Java is not installed on your machine or your browser does not allowed Java Applet to run<br /><br />Get the latest Java technology at <a href="http://www.java.com/">http://www.java.com/</a> 
    </applet> 
    </body> 
    </html>
    the name is app.jar and the content is only 1 file, Chat.class

    its simple class which extends Applet
    and draws a circle
    altough when i load the webpage it doesn't show anything, nor a java sign or w/e

    Any ideas??

    Thanks in advance!
    Last edited by jonasdb; 11-02-2009 at 09:12 AM.

  2. #2
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: Jar application, what is the classpath?

    can you attach the jar file here. So we can check it too.
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  3. #3
    jonasdb is offline x10Hosting Member jonasdb is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    19

    Re: Jar application, what is the classpath?

    Ok sure,but i cant attach it lol :p
    ill uploaded: http://basketsite.x10hosting.com/app.jar

    content of Chat.java

    package chat;

    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;

    public class Chat extends Applet
    {

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    public static void main(String[] args)
    {
    Chat c =new Chat();
    }



    public void paint( Graphics g )
    {
    super.paint( g );
    g.setColor(Color.RED);
    g.fillRect(0, 0, 500, 500);
    g.drawRect( 900, 40, 30, 900 );
    g.fillRect( 200, 70, 80, 80 );
    g.fillOval( 100, 50, 40, 100 );
    g.drawOval( 100, 200, 100, 40 );
    int X = 250, Y = 225;
    int r = 25;
    g.drawOval( X - r, Y - r, r * 2, r * 2 );
    }

    }
    -> http://basketsite.x10hosting.com/app.jar
    Last edited by jonasdb; 11-02-2009 at 09:29 AM.

  4. #4
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: Jar application, what is the classpath?

    One thing I noticed:
    Code:
    code="Chat.class"
    This is wrong: it should be "chat.Chat" - The 2 errors are:
    a) No need to mention .class in the name
    b) The package has to be mentioned.

    Also the jar file has the wrong structure, Chat.class should be in a folder called chat, since it is part of the package chat.
    Last edited by ah-blabla; 11-02-2009 at 10:58 AM.

  5. #5
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: Jar application, what is the classpath?

    I tried to run in firfox.

    In java console it is showing an exception

    java.lang.UnsupportedClassVersionError: Bad version number in .class file

    Check out. I will try to recompile and try to run it again.


    EDIT:

    There is one more thing in your jar

    It contains chat.class nothing else;

    But in the code it is given as package chat.

    That means the class file must be inside chat folder and when you are trying to make jar
    give application entry point..

    It will work...
    Last edited by Gouri; 11-02-2009 at 10:55 AM. Reason: updated
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  6. #6
    jonasdb is offline x10Hosting Member jonasdb is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    19

    Re: Jar application, what is the classpath?

    Ok thanks guys ill check it out asap!

  7. #7
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: Jar application, what is the classpath?

    Quote Originally Posted by gsonline View Post

    java.lang.UnsupportedClassVersionError: Bad version number in .class file

    Check out. I will try to recompile and try to run it again.
    That probably means you are using a jre older than the jdk the file was compiled with. E.g. if you are using java 4 (1.4) and you try running something compiled with java 6 (1.6) then you will get a version error, since the older jre doesn't understand the newer code (unless you set the compiler to compile with 1.4 compliance level, in which case it will generate code of older spec, which will work with an older jre).

  8. #8
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: Jar application, what is the classpath?

    Quote Originally Posted by ah-blabla View Post
    That probably means you are using a jre older than the jdk the file was compiled with. E.g. if you are using java 4 (1.4) and you try running something compiled with java 6 (1.6) then you will get a version error, since the older jre doesn't understand the newer code (unless you set the compiler to compile with 1.4 compliance level, in which case it will generate code of older spec, which will work with an older jre).
    Actually i have 2 versions with me now. 1.5 and 1.6 after seeing the manifest file i changed jre and now the exception is eliminated....
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  9. #9
    jonasdb is offline x10Hosting Member jonasdb is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    19

    Re: Jar application, what is the classpath?

    Ok guys, i tried doing what you said, but unfortunately i still doesn't work.

    This is what i did: create a new folder with the name 'chat', but the compiled class of Chat.java in it, used JARMaker to jar the folder, now i tried setting the path right with and without the .class, i tried change the archive also but unfortunately i wasn't be able to fix it.

    If anyone could try it with my files, here they are:
    http://basketsite.x10hosting.com/app5.html
    http://basketsite.x10hosting.com/app5.jar

    I also found there was an option about the manifest file, i put the classpath in it (just unzip the jar and you'll see it), it might be incorrect, but i tried alot but still it doesn't work

    Any help is appreciated!
    Thanks for all the help already!

  10. #10
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: Jar application, what is the classpath?

    Quote Originally Posted by jonasdb View Post
    Ok guys, i tried doing what you said, but unfortunately i still doesn't work.

    This is what i did: create a new folder with the name 'chat', but the compiled class of Chat.java in it, used JARMaker to jar the folder, now i tried setting the path right with and without the .class, i tried change the archive also but unfortunately i wasn't be able to fix it.

    If anyone could try it with my files, here they are:
    http://basketsite.x10hosting.com/app5.html
    http://basketsite.x10hosting.com/app5.jar

    I also found there was an option about the manifest file, i put the classpath in it (just unzip the jar and you'll see it), it might be incorrect, but i tried alot but still it doesn't work

    Any help is appreciated!
    Thanks for all the help already!
    That jar file still is incorrect: Chat.class is in the top folder, and should be in the folder chat. I made a test page to which I uploaded the applet:
    http://www.ahunt.org/java.html
    Code:
    <html><body>
    <applet code="chat.Chat" archive="http://www.ahunt.org/chat2.jar" width="600px" height="450px" /> 
    </body></html>
    I also compiled and "jarred" the java file, here:
    http://www.ahunt.org/chat2.jar
    This file has the structure:
    >META-INF
    -----------------| MANIFEST.MF
    >chat
    -----------------| Chat.class

    To make life easier, try remove the package declaration from Chat.java, and then change the starting point in the html file to Chat

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Extreme Vulnerabilities
    By RockiMoon in forum Graphics & Webdesign
    Replies: 0
    Last Post: 01-21-2009, 04:11 AM
  2. Replies: 2
    Last Post: 03-15-2008, 01:10 PM
  3. PHP version application
    By Fr33z4r in forum Free Hosting
    Replies: 3
    Last Post: 11-04-2007, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers