How to modify a specific class in jar file ?

I've downloaded a jar file for applet, the jar file works fine... but when I extract a specific class file from the jar file and just recompie it from my IDE (Eclipse) without even making any change and then compress again jar class files including the new modified class file instead of the old one (without any modifications to other classes)... then I get
(NoSuchMethodError ) exception whenever methods of other classes are invoked from within the modified class !!
...The manifist file of the jar file reads the following line
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
I thought it means that jar class files were built using JDK 1.4.0_01 ...I used JDK 1.5.0_01 in my IDE...
I thought JRE incompatiblity was the reason of the problem so I downloaded JRE 1.4.0_01 and used it to build this class file... but i got the same exception..
so what is the main reason of the problem ? ...should I make changes to IDX files accompanying applet jar files ??
If no, then how can I overcome this problem and be able to change and rebuild a specific class from this jar file ?
(I cannot rebuild all classes in jar because there are errors I cannot resolve !!)

Could you please clarify: do you want to run your project or a project from an independent jar?
In the first case just select Run Project from the project context menu or select a class with main method and click Run File in the class context menu.
Regarding the second case:
- I don't think there is such a feature in the IDE (running third party jars is not an IDE function). Could you explain why you need this?

Similar Messages

  • How to bundle java help class into jar file ?

    Hi, all,
    I have some package in my project, with which I have a java help jar file as classpath, when I run my project, I need the jh.jar file in directory /jar/jh.jar.
    Now, I bundled all my class packages into a jar file, my.jar, together with the /jar directory. When i run my jar file with command:
    java -jar my.jar
    It tells me couldn't find javahelp class.
    What shall I do? How can I create my jar file with the jh.jar?
    Thanks in advance.

    I think you'd be better off just adding the jh.jar as
    a classpath argument and running it like that:
    java -classpath /myjavalibdir/jh.jar -jar myjar.jar
    ...otherwise you're stepping into redistribution of
    binary issues licensing-wise. That won't work either; when you run java with the -jar option, it ignores both the -classpath option and the CLASSPATH environment variable. However, it will see jh.jar automatically if you put it in the <path-to-java>/jre/lib/ext directory. But for distribution purposes, it might be simpler just to combime the contents of jh.jar into myjar.jar (if you use Ant, its <jar> task makes that very easy). Or, you can just run it this way:java -classpath myjar.jar;jar/jh.jar MyMainClassBTW, I don't think redistribution is a problem; otherwise how anyone even use JavaHelp?

  • How to compile .java to .class in .jar file

    Hey. I have code to make a .jar file, read .java files, and save them as .class files in the .jar file. When I open the .jar file, it says that the magic numbers on the classes are wrong. So I figured that Java must compile the .java files to .class files in bytecode.
    Question: What's the code to compile a string from a .java file to a .class file?
    Here's my code:
    try {
                // Name of jar file to write
                String archiveFile = Name + ".jar";
                Manifest jman = new Manifest();
                try {
                    // Create a manifest from a file
                    //InputStream fis = new FileInputStream("manifestfile");
                    //Manifest manifest = new Manifest(fis);
                    // Construct a string version of a manifest
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("Manifest-Version: 1.0\n");
                    sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
                    sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
                    sbuf.append("Main-Class: Main\n");
                    sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
                    sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
                    // Convert the string to a input stream
                    InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
                    // Create the manifest
                    jman = new Manifest(is);
                } catch (IOException e) {
                FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
                JarOutputStream out = new JarOutputStream(stream, jman);
                out.putNextEntry(new JarEntry("Main.class"));
                StringBuffer sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("Main.txt")));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("MainScreen.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("MainScreen.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("GCanvas.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("GCanvas.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.close();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.toString(), "BUG!", JOptionPane.INFORMATION_MESSAGE);
                ex.printStackTrace();
            }Thanks,
    -Gandolf

    So I'm guessing that none of you guys have the knowledge on how to compile a java application within a java application. I was thinking that it had something to do with javac... but I'm unsure.
    If no one can answer the question, could someone point me to an expert who would know?
    -Gandolf

  • How to modify the timestamp in a msg file?

    Hi All,
    Do you know how to modify the timestamp in a msg file which was saved from Outlook Inbox. The mail subject and body are able to be modified by selecting
    Actions - Edit Message. But it looks like the mail timestamp and the To/Cc are not able to be modified.
    Thanks,
    高麻雀

    You can convert your MSG file(s) to EML format, edit Date: header in EML file with any plain text editor (like Notepad) and then convert it back to MSG.
    You can use free
    Convert Outlook MSG to EML Files and
    Convert EML Files to Outlook MSG utilities to perform the conversion.
    Alexey Kuznetsov,
    Relief Software
    More than 100 free add-ins for Outlook

  • How to extract the contents of the Jar file?

    Hello,
    Can anyone tell me how to extract the contents of the Jar file?
    An example will be highly appreciated.
    Thanks.

    From command line, or from within a java application?
    Kaj
    Btw. Why do you need to do it. You do know that you can add jars to the classpath and read resources from them without extracting the file?

  • Can I increase heap memory without specify any class or jar file??

    Hi,
    I tried to increase my heap memory in this way :
    java -Xms256m -Xmx256m
    but I got an error ... it's seem that I must specify a class java or a .jar file ...
    This is the error :
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image
    can I increase heap memory without specify any class or jar file??
    thx

    chiara wrote:
    Hi,
    I tried to increase my heap memory in this way :
    java -Xms256m -Xmx256m
    but I got an error ... it's seem that I must specify a class java or a .jar file ...
    This is the error :
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    can I increase heap memory without specify any class or jar file??The job of java.exe is to execute java bytecode.
    What is it supposed to do with your request to use 256m of memory for heap
    when you are not giving it a class or a jar to run?

  • Where to put common classes and jar files

    hi,
    i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being accessed easily ,but i am having problems with sun one .
    Regards
    Ameem Sami

    Did you find a solution for this? I'm having the same problem.
    Thanks,
    Tony

  • Ojvmtc reports xy.jar is not a class or jar file

    Hi
    I am a little bit confuced because ojvmtc reports an error I can not imagine about:
    oracle@cikic-desktop:~/Downloads/dom4j-1.6.1$ ojvmtc /u01/app/oracle/product/11.1.0/mds/jdk/jre/lib/jce.jar
    /u01/app/oracle/product/11.1.0/mds/jdk/jre/lib/jce.jar is not a class or jar file
    The set is closed
    But jce.jar is a jar file and I can inflate it:
    oracle@cikic-desktop:/tmp/fo$ jar -xf /u01/app/oracle/product/11.1.0/mds/jdk/jre/lib/jce.jar
    oracle@cikic-desktop:/tmp/fo$ ls -l
    total 8
    drwxr-xr-x 3 oracle oinstall 4096 2010-05-03 19:40 javax
    drwxr-xr-x 2 oracle oinstall 4096 2010-05-03 19:40 META-INF
    And if I do a ojvm on a class file everything is working like expected:
    oracle@cikic-desktop:/tmp/fo$ ojvmtc javax/crypto/Mac.class
    The set is not closed
    96 classes are missing
    So It must be a configuration mistake somewhere ...
    Can you please help me out.
    Thanks
    Christian Maier

    Coole thanks, this works pretty well!
    Chris
    oracle@cikic-desktop:~$ cp /u01/app/oracle/product/11.1.0/mds/jdk/jre/lib/jce.jar /tmp/
    oracle@cikic-desktop:~$ ojvmtc /tmp/jce.jar
    The set is not closed
    131 classes are missing

  • How to load class from jar file dynamically?

    After I run my Java applicatoin, I need configuring the classpath of jvm to load some classess inside a jar file into the same jvm.How can I achive that?
    I mean, when I run my Java application, I don't know where the jar file is, what the jar file name is. All depends on the user to tell the jvm the details through some UI. I've tried to write: System.setProperty("java.class.path", "c:\myClass.jar");Class.forName("MyClass"); but failed.
    Can you tell my why and how?
    Thx

    After I run my Java applicatoin, I need configuring
    the classpath of jvm to load some classess inside a
    jar file into the same jvm.How can I achive that?
    I mean, when I run my Java application, I don't know
    where the jar file is, what the jar file name is. All
    depends on the user to tell the jvm the details
    through some UI. I've tried to write:
    System.setProperty("java.class.path",
    "c:\myClass.jar");Class.forName("MyClass"); but
    failed.That won't work. By the time it gets to your code it already has a copy of the original. You can't change it (short of modifying the JVM.)
    Can you tell my why and how?The usual way is to use a custom classloader.
    You can start by looking at java.net.URLClassLoader.

  • How to convert .class into .jar file

    Hi,
    How to convert .class into .jar file

    jsf_VWP5.5.1 wrote:
    Hi,
    How to convert .class into .jar fileFrom a command prompt, cd to the location of your .class file(s).
    If you want to create a simple jar, use: jar -cf Whatever.jar Whatever.class
    If you want to compile all .class files in a directory into a jar, use *.class instead.
    Now, I'm going to assume you want to create an executable jar... here's how to do that:
    1) Create a blank text file; for this example, lets call it main.txt.
    2) In the first line of main.txt, type: Main-class: Whatever ('Whatever' should be the name of the class in your program where the main() method is located)
    3) Press enter to go to the next line (someone please correct me if I'm wrong, but if you don't insert the line break/CR after the Main-class: statement, this will not work... in my experience, this is true)
    4) Make sure you save this file in the same directory as your .class file(s).
    5) Type: jar -cmf Whatever.jar main.txt Whatever.class
    ...and that's about it. For more information on the usage of the jar command and to understand the switches (such as -cmf), try jar --help.
    Hope that helps.

  • How to access classes in jar files

    hi I have added a jar file to my project in eclipse.How to access the classes in that jar file?

    cu is right.
    classloader returns the URL of your resource. You can the jar using something like the following...
    ClassLoader classloader = this.getClassLoader();
    url = classloader.getResource("your_resouces...");
    if(url == null)
    System.out.println("cannot find resource ");
    return null;
    String jar = url.getFile();
    jar = jar.substring(jar.indexOf("/")+1, jar.lastIndexOf("!")).replace('/', '\\');
    obviously, this code snippet works on windows only. Now you have the jar file path. I use Jar file classes to access the jar file. (e.g. you can search for each class files)
    Ming

  • Can we send java classes instead jar files through web start?

    HI,
    As we all know through web start we can send jar files from server to client system and run application. is it possible to send only java class file directly without making it jar? if yes then how it is?

    no - not possible in jnlp specification.

  • How to package an application as a JAR file?

    I want to package an executed JAR file,how to do?
    "jar cvf jar_name class_name"? But it can't run,:( help me.
    Thanks in advance.

    Suppose your main class call MyMainClass. You need to create a file called "mymanifest". In the mymanifest file, you need to include following line:
    Main-Class: MyMainClass
    Then you need to jar your jarfiles by:
    jar cvfm classes.jar mymanifest -C foo/ .
    After this, you can run your jar file by java -jar classes.jar.

  • How can I reference more than one jar file

    hi, In an applet, I use
    Archive = "foo.jar" to reference this jar file.
    But how can I reference more than one file?
    Thanks.

    Suggestion: spend a few minutes reading the tutorials.
    http://java.sun.com/docs/books/tutorial/applet/appletsonly/html.html
    You can specify multiple archive files by separating them with commas:
    <APPLET CODE="myapplet.class" ARCHIVE="file1, file2"     WIDTH=anInt HEIGHT=anInt>
    </APPLET>

  • How to create package and import from jar file?

    Hi all,
    I am writing a software and I am not sure how to create a package for the classes.
    Say I have two classes in the same directory as follows:
    testA.java
    ==========
    package AB;
    public class testA
    public static void main(String[] args){
         testB myB = new testB();
         System.out.println("A test");
    testB.java
    ===========
    package AB;
    public class testB
    public testB(){
         System.out.println("B constructor");
    both file compile without the package heading;
    both file compile using: javac -classpath .\ *.java
    Question 1:
    I cannot run testA by: java -classpath .\ testA
    I think it is a syntax error. What is the correct one?
    If I run testA by: java testA
    The only output I get is: A test
    But I am expecting: B constructor /n A test
    What went wrong?
    Question 2:
    I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
    I have read a couple of tutorials but they don't answer my question.
    (I am using windows2000 and don't have the classpath variable.)
    Hope some one can help.
    Thanks a lot

    Try moving testA out of the package and importing 'AB.*;'
    If you have:
    ./testA.class
    ./AB/testb.class
    Then to execute testA from ./ type: java -cp . testA

Maybe you are looking for

  • Image processing Manupulation problem!!!

    Dear all, God Morning! hope u all are fine .. i have an issue regarding Image processing Manipulation. i want to give u all the details.. what i have done so far in java. i have used third party tool of java called ImageJ editor for image manipulatio

  • Message encode from mobile device

    Message received encoded koi8-r was forwarded from a mobile device connected to Exchange 2010 with the header was encoded in windows-1251 and the message body in koi8-r and accordingly the recipient(user) could not read it. How can I fix these errors

  • Edit page not working in Contribute

    I have a site that I administer in Contribute, a user called today because they are not able to Edit a page. When you click the Edit button it just sits there. As the Administrator I try to go into the file and I can't get into it either. I even recr

  • Error in JMS

    Hi I tried the following code to connect to a JMS server which is running on a remote machine.. String strConnectionFactory="java:comp/env/jms/sample";                String strTopic="java:comp/env/jms/Computer";                Hashtable env = new Ha

  • HT1338 help with installing Mountain Lion software...!

    i am trying to update my mac book pro with the mountain lion software. i have purchased this in my mac app store but do not see where to go from here to install... anyone know what to do? do i not have enough space to install the update? how do i tel