Jar manipulation

Hi all,
What is the easiest way to append a line to a text file that is contained in a jar file ?
Thank you

Gen.Java wrote:
Parul Garg wrote:
suppose you want to fetch txt file from class named Utilities :-I need to fetch it from a jar file not from a class.That's what getResource[AsStream] does. The classloader looks for the data in the same place that it looks for .class files.
You're probably better to use e.g.
InputStream is = getClass().getClassLoader().getResourceAsStream(path);The difference is that the path is from the root of the .jar file rather than relative to the class package directory.

Similar Messages

  • How to prevent jar manipulation

    We want to deploy an application with java webstart/jnlp and we must assure that at least the core jar is free from modifications.
    I spent days reading FAQs and forums but two security issues are still on my mind.
    Scenario 1:
    The attacker downloads the jar with the informations fro the jnlp file. He decomplies the classes and removes the signitures out of the meta.inf put it all together in a jar and starts the jar locally.
    Scenario 2:
    The attacker sets up his own web server and places the manipulated jnlp file, jar file(s) and all the other files on this server. He could even direct the dns of our server to his own, which is very simple in windows. Java Webstart could never know that the manipulated jar is the wrong one.
    So if anyone knows a solution for these scenarios than please let me know
    With best reguards.

    Scenario 2 is a simple trust problem that happens with every secured application (an HTTPS site, for instance):
    1) you can have your certificate released by a CA
    2) you can distribute certificate MD5 and SHA1 hash on a safe channel (ordinary mail): when downloading signed app user is requested to accept certificate (and can view hashes), all he has to do is compare it with the one you distributed
    Scenario 1: you can scramble jars; if you use active code to expose jars you can check requesting user agent to prevent everything other then JWS to download them (it's hard to bring them out of cache); you can add a conditional check to be sure code is running on jws; you can have a small jar required to run that you remove from cache everytime application starts .. but it's code! there's no way you can prevent people breaking it on their own computer, you can just make it hard!
    Have fun.

  • Jar manipulation - 2

    Hi all,
    I need to remember an API that I used a long time ago (which I cannot remember now) that enabled me to read the contents of a file. This API accumulates what is read in an internal buffer which I can get its contents with a single call.
    Thank you

    malcolmmc wrote:
    You are probably thinking of maping an file channel into a byte buffer. What this actually does is to use the machine's virtual memory system to access the file data as if it were memory.No, it is something like java.io.ByteArrayInputStream() where I can get its internal buffer contents.
    Can be useful for randomly accessing file data, but no use I can think of for jar files.I need to read the contents of a file that is inside a jar file so that I can append a line to it.
    Modifying an entry in a jar file would be incredibly messy because it's usually compressed, and generally not at the end of the file. So the size of the entry would change, and all subsequent data in the file would need to be moved up or down (plus adjusting any offsets).Wouldn't getting a JarURLConnection for it and then getting its InputStream uncompress it.
    Not sensible. Especially if it's the program's jar, which will be read-locked by the operating system while running so that you won't be able to obtain write access anyway.Thanks for this info. it is good to know that.
    Almost certainly Prefferences is what you need.Certainly this wouldn't help, but I can understand why you suggested it.

  • How to make an applet to read the Text file present inside a jar

    Hi All,
    I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
    The applet code runs successfully when i run the applet in command prompt like
    {color:#ff0000}*java ReadFile*{color}
    And i am getting the needed results.
    Then i made a jar file with the applet code and text file as
    {color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
    Then i have inlcuded this applet inside a html file as
    {color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
    after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
    Applet is not recognizing trhe text file present inside the jar file.
    Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.

    what code in your applet gets the text file and reads it? are you using getResource or something similar?

  • Parsing xml with dom4j - cannot find jar file

    Hi,
    I'm using Jdeveloper 10g and tomcat 5.5.9. I have a servlet which calls a java class (ParseXML.java) that trys to parse an xml string using dom4j. A snippet of ParseXML.java...
    import org.dom4j.Document;
    import org.dom4j.DocumentException;
    import org.dom4j.io.SAXReader;
    public class ParseXML  {
    public ParseXML(String xml) {
              this.XML_STRING = xml;
         public String parse() {
              SAXReader reader = new SAXReader();
              Document document = null;
              try  {
                   document = reader.read(XML_STRING);
                   } catch (DocumentException de)  {
                   return de.getMessage();
              } catch (Exception e) {
                   return e.getMessage();
                   return "The xml root value is: " + document.getRootElement().getName();
    } I've downloaded the dom4j 1.6.1 jar and put it on the project class path (specified in the jdev project proerties), and my code also compiles ok. But when i try to instantiate ParseXML from my servlet i get a runtime exception:
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoClassDefFoundError: org/dom4j/DocumentException
         arcims.GetMapServlet.doPost(GetMap.java:45)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802I'm not sure if this is a class path issue or something else; i've checked and rechecked the classpath and nothing seems amiss.
    Suggestions, anyone?

    Question: Is it really necessary to use a
    StringReader if my xml document is not saved to disk?
    I get XML_STRING from a web service, convert it into
    a xml document so i can manipulate/parse it, but then
    i don't save the document, i just discard it. How
    does my system's default character set affect string
    manipulations that i do within my java app?Your system's default charset doesn't have anything to do with string manipulations, if by that you mean substrings and concatenations of strings. It is used when you convert strings to bytes and bytes to strings. If your string contains a character that can't be handled by your default charset, then converting that string to bytes will put ? in place of that character. Converting those bytes back to a string will leave the ? as is. Thus your string has been changed.
    Also converting the string to bytes can have bad results, because the first thing the XML parser does is to convert the bytes back to a string, using the charset declared in the XML. If this charset is different from your system's default, then your XML may be corrupted by this process if it contains characters that are encoded differently in the two charsets. The typical example of this is European accented letters like �, which are encoded differently in ISO-8859-1 or Windows-1252 (most people's default charsets) and UTF-8 (the default XML charset).
    Besides, converting the string to bytes just so it can be immediately converted back to a string is rather wasteful.

  • Entity manager outside of entities jar

    Hi,
    Is it possible to keep perisitence unit (persistence.xml) in different jar than etities?
    I would like to store all entities in one jar and treat them as DTO and put that jar in several modules (web module, EJB module), but logic of data manipulations store only in business module.
    For me it doesn't work even in simple example:
    public static void main(String[] args) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestPU");
    EntityManager em = emf.createEntityManager();
    Object o = em.find(pkg.Uzytkownik, new Integer(10));
    I get exception:
    Exception in thread "main" java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "pkg.SloStawka"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.Class.forName(Class.java:247)
    at oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.getClassForName(PrivilegedAccessHelper.java:97)
    On the web server with similar code in EJB module I get:
    Caused by: java.lang.IllegalArgumentException: Unknown entity bean class: class pkg.Uzytkownik, please verify that this class has been marked with the @Entity annotation.
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.findInternal(EntityManagerImpl.java:306)
    at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.find(EntityManagerImpl.java:148)
    In all modules I have only one class with name Uzytkownik and it contains:
    @Entity
    @Table(name = "uzytkownik")
    public class Uzytkownik ...
    The same result is both with Toplink 9.1 build: b36-rc and Toplink 11
    best regards,
    artur

    Dorbsz,
    Strangely, I tried it again about a month later, and it worked! I have no explanation other than perhaps the container had malfunctioned and it needed to be restarted.
    Another thing, is that it may+ have started working about the time that I began using the @Version entity annotation.
    So here is that I would try in this order:
    1. Restart the container
    2. Try adding the @Version annotation to a field on the entity (will need a database column to correspond to)
    3. If 1 and 2 fail, you can create a named query with a Toplink hint that informs Toplink not to get the entity from the cache, so in stead of using refresh, you would execute that query.
    I was doing number 3 for a while, and it works, but it is obviously not the best solution. I don't have a link at the moment, but if you goolge with keywords like "toplink refresh hint cache" you should find an example of how to do it. Oracle also has all of the Toplink hints documented.
    If you have a lot of trouble finding an example, I could possibly post my named query that did this. Only go this route as a last resort though.
    Kurzweil4

  • How do you monitor required JAR(s) being downloaded?

    Hi there,
    I'm currently re-developing an existing signed applet (Swing / 1.4) to offer advanced image manipulation features.
    As a result there is a massive increase in the size of download and the amount of JARs to be downloaded from 1 (app 50kb) to 3 (app total 2MB) as I have to include the JAI.
    Can anyone tell me is there a way of monitoring the downloading of the JARs from the applet itself or perhaps an external means so that I can display a progress monitor for the user while the application is loading?
    Thanks in advance,
    Fergus.

    If you are using 1.4 you can specify in your applet tag structure that you wish to include a progress bar for your applet. Moreover you can provide a descriptive message to appear as your applet is loading...
    You specify this information using the param tags within your applet or object tag.
    <param name = "progressbar" value = "true">
    <param name = "boxmessage" value = "Please wait while the applet loads.">

  • Using external Jar with a mobile application

    Hi folks!
       I need some help with my application, i make a simple mobile application and i need to use a external jar, in this case, this jar have a simple JAVA class that represents a manipulation with eSWT, so my problem is How to using external Jar in NetWeaver 7.1?
       I see other threads that have a same doubts, but i don´t have a solution for my problem.
       Thats it.

    Hi Sivakumar,
    I have similar problem. i want use iText or similar jar files to create pdf. I have currently developed a UI component for handheld. I have dont the following things:
    1)Created a external dc of type external library
    2) addedd the jar in the build path
    3) added the jar in the lib folder of the webdynpro project
    4) added the external jar dc as dependency in my webdynpro project
    I am getting no class def found eror still for some wierd reason. please let me know if some step is missing. I have pasted the trace.
    rror starting the framework
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sap.tc.mobile.cfs.startup.pda.Startup.main(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: com/cete/dynamicpdf/Font
         at com.sap.demo.testui.testapp.comp.SignatureStandard.runApps(SignatureStandard.java:88)
         at com.sap.demo.testui.testapp.comp.TestCompView.wdDoInit(TestCompView.java:85)
         at com.sap.tc.mobile.wdlite.progmodel.core.Controller.enter(Controller.java:21)
         at com.sap.tc.mobile.wdlite.progmodel.core.View.enter(View.java:45)
         at com.sap.tc.mobile.wdlite.progmodel.core.Application.setCurrentView(Application.java:133)
         at com.sap.tc.mobile.wdlite.progmodel.core.Application.navigate(Application.java:169)
         at com.sap.tc.mobile.wdlite.progmodel.core.Application.enter(Application.java:19)
         at com.sap.tc.mobile.wdlite.progmodel.core.WDLite.setCurrentApplication(WDLite.java:148)
         at com.sap.tc.mobile.wdlite.progmodel.core.WDLite.launchApplication(WDLite.java:80)
         at com.sap.tc.mobile.wdlite.container.ContainerApp.startApp(ContainerApp.java:171)
         at com.sap.tc.mobile.wdlite.container.AppMenuView.onActionLaunchApp(AppMenuView.java:325)
         at com.sap.tc.mobile.wdlite.container.AppMenuView.invokeEventHandler(AppMenuView.java:368)
         at com.sap.tc.mobile.wdlite.progmodel.core.AbstractViewElement.doHandleEvent(AbstractViewElement.java:199)
         at com.sap.tc.mobile.wdlite.renderer.api.UIElement.doHandleEvent(UIElement.java:369)
         at com.sap.tc.mobile.wdlite.renderer.api.UIImageButton.mouseReleased(UIImageButton.java:148)
         at com.sap.tc.mobile.wdlite.renderer.api.UIElement.dispatchMouseReleasedWidgetEvent(UIElement.java:412)
         at com.sap.tc.mobile.wdlite.renderer.api.UIElement$1.mouseReleased(UIElement.java:455)
         at com.sap.tc.mobile.wdlite.renderer.swt.MouseEventDispatcher.mouseUp(SWTControl.java:380)
         at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:137)
         at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
         at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)

  • Getting the Adapter Class Not Found Error in the Java Manipulator

    Hi,
    I wrote a custom java manipulator for the baseline update and created a jar file for the class. This works fine in the Windows machine. All I have to do is while specifying the CLASSPATH, I entered the ./ib/newManipulator.jar; ./lib/additional_dependency.jar. When I tried to deploy the same code in the Unix environment, it fails saying the Adapter Class not found. The only difference from windows and Unix environment is that in the windows machine, in order to run the base line update, I go to the directory my_project->control->baseline_update.bat but in case of Unix environment I have a separate location where I have a shell script called run-baseline-update.sh located at /apps/bin which invokes the baseline.sh in the directory my_project/control/baseline.sh. I even tried to put the full path of the jar files e.g. /my_project/lib/newManipulator.jar; /my_project/lib/additional_dependency.jar in the class path but still the same issue. Any suggestions?

    Unix classpath needs ":" as the path separator, not ";". Changing that will make this work.
    For reference, later versions of the deployment template make this configurable, so you'd see (in environment.properties):
    # PATH_SEP_VARNAME: for platform-independence
    PATH_SEP_VARNAME=;
    # Forge needs record store libraries as well as Spring to load record store adapter configuration files
    FORGE_CLASSPATH=./config/lib/java/spring-delegate-adapter-1.0.1.jar${PATH_SEP_VARNAME}./config/lib/java/spring.jar${PATH_SEP_VARNAME}./config/lib/java/eacToolkit.jar${PATH_SEP_VARNAME}./config/script${PATH_SEP_VARNAME}.
    You can then add the following to your <forge /> definition in AppConfig.xml:
    <arg>--javaClasspath</arg>
    <arg>${FORGE_CLASSPATH}</arg>
    Hope this helps.
    Michael

  • Incorporating .jar files into Batch files

    Hello, I've created an application that requires .jar files to operate correctly. I was able to get them into eclipse, which made me happy. I was able to figure out how to get them into a .html file when I went to put it on the web which made me even happier. But, then I discovered that I cannot use a html file to call it because of the security access exceptions that are ensued by placing the application on the web. I've come to the conclusion that I will use a Batch file (.bat) to run the app. The way I knew how to get them into the html file was to use:
    <applet code="MYCLASS.class" archive="MYCLASS_JARFILE.jar">
    </applet>Now I need to figure out how to achieve the same effect as that into a batch file that uses:
    java MYCLASSAny help would be greatly appreciated. Thanks.

    The applet uses I/O from a MySQL server. When launching it through the website (Not where the database is hosted from) the applet causes the following exception:
    java.net.SocketException: java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:3306 connect,resolve)The applet in the end will be placed on the same server as the database but I was unsure if this issue would still persist, assuming it would I converted the applet into and executable JAR file and run it through the batch file which does not cause the same error.
    I read up on the signing applets and such and saw in most forums and articles, that it was a hard way to go and was a hassle. I also found out other articles advocating the use of applet--->servlet--->database however, I know very little about servlets. Currently I only have a semester of Java and have been constantly practicing it since the end of the semester. I learned MySQL and how to use it and right now I have an applet that stores and reads data from the MySQL server I've set up on my home network and uses a java applet GUI to allow manipulation of the data.
    Edited by: sfeher1 on Jul 21, 2009 9:36 PM

  • Apache Tomcat 7.0.4 can't recognize the classpath for .jar files

    Hiii Everybody,
    I have a weird problem. I am trying to develop a simple application where I am trying to pass an excel file name as an argument to a method and the method creates a copy of the specified file. I have used jxl.jar for excel file manipulation. During this I have faced two problems.......
    1) I tried to compile the file CopyExcel.java in the command prompt(windows), sometimes the file is not compiled and the error shown indicates that it can't recognize the package jxl. But if I close the command prompt window and open it again.... I could compile the CopyExcel.java succesfully with no error.
    2) Even if I have compiled the CopyExcell.java file successfully, whenever I am tryiyng to call a method copyMain() inside it, browser shows....
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoClassDefFoundError: jxl/Workbook
         CopyExcel.copy(CopyExcel.java:39)
         CopyExcel.copyMain(CopyExcel.java:81)
         ServicePage.processRequest(ServicePage.java:28)
         ServicePage.doPost(ServicePage.java:73)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    java.lang.ClassNotFoundException: jxl.Workbook
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
         java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
         CopyExcel.copy(CopyExcel.java:39)
         CopyExcel.copyMain(CopyExcel.java:81)
         ServicePage.processRequest(ServicePage.java:28)
         ServicePage.doPost(ServicePage.java:73)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.4 logs.
    --------------------------------------------------------------------------------The code for CopyExcel.java is as folows.............
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Administrator
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.io.File;
    import java.io.IOException;
    import jxl.Cell;
    //import jxl.CellType;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;
    import jxl.write.WritableWorkbook;
    public class CopyExcel {
         private String inputFile;
         public void setInputFile(String inputFile) {
              this.inputFile = inputFile;
         public void copy() throws IOException  {
              File inputWorkbook = new File(inputFile);
              Workbook w;
                    try{
                        System.out.println("Before w= Workbook.getWorkbook(inputWorkbook);  ");
              w= Workbook.getWorkbook(inputWorkbook);
                     System.out.println("After w= Workbook.getWorkbook(inputWorkbook);  ");
              WritableWorkbook copy=Workbook.createWorkbook(new File("CopyPan.xls"), w);
                    copy.write();
                    copy.close();
                    }catch(Exception e){}
    /*          try {
                   w = Workbook.getWorkbook(inputWorkbook);
                   // Get the first sheet
                   Sheet sheet = w.getSheet(0);
                   // Loop over first 10 column and lines
                        for (int i = 1; i < 6; i++) {
                             Cell cell = sheet.getCell(0, i);
                             //CellType type = cell.getType();
                             //if (cell.getType() == CellType.LABEL) {
                                  //System.out.println("I got a label "
                                       //     + cell.getContents());
                             //if (cell.getType() == CellType.NUMBER) {
                                  //System.out.println("I got a number "
                                            //+ cell.getContents());
                                                    System.out.println(cell.getContents());
              } catch (BiffException e) {
                   e.printStackTrace();
         public static  String copyMain(String args) throws IOException {
              String str=args;
              CopyExcel test = new CopyExcel();
              test.setInputFile(args);
              test.copy();
                    return "Success";
    }I have set the "CLASSPATH" environment variables in "user variables for administrator" as follows,
    .;%SYSTEM%;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\bin;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_11\lib\jxl-2.6.jar Also I have tried editing the startup MS-dos batch file as folows....
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11
    set CLASSPATH=.;%SYSTEM%;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\bin;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_11\lib\jxl-2.6.jar
    @echo off
    rem Licensed to the Apache Software Foundation (ASF) under one or more
    rem contributor license agreements.  See the NOTICE file distributed with
    rem this work for additional information regarding copyright ownership.
    rem The ASF licenses thi..........But the problem remained...........
    Plz. help me.
    Thank u in advance for any help.

    Hiii Everybody,
    I have a weird problem. I am trying to develop a simple application where I am trying to pass an excel file name as an argument to a method and the method creates a copy of the specified file. I have used jxl.jar for excel file manipulation. During this I have faced two problems.......
    1) I tried to compile the file CopyExcel.java in the command prompt(windows), sometimes the file is not compiled and the error shown indicates that it can't recognize the package jxl. But if I close the command prompt window and open it again.... I could compile the CopyExcel.java succesfully with no error.
    2) Even if I have compiled the CopyExcell.java file successfully, whenever I am tryiyng to call a method copyMain() inside it, browser shows....
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoClassDefFoundError: jxl/Workbook
         CopyExcel.copy(CopyExcel.java:39)
         CopyExcel.copyMain(CopyExcel.java:81)
         ServicePage.processRequest(ServicePage.java:28)
         ServicePage.doPost(ServicePage.java:73)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    root cause
    java.lang.ClassNotFoundException: jxl.Workbook
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
         java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
         CopyExcel.copy(CopyExcel.java:39)
         CopyExcel.copyMain(CopyExcel.java:81)
         ServicePage.processRequest(ServicePage.java:28)
         ServicePage.doPost(ServicePage.java:73)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.4 logs.
    --------------------------------------------------------------------------------The code for CopyExcel.java is as folows.............
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    * @author Administrator
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.io.File;
    import java.io.IOException;
    import jxl.Cell;
    //import jxl.CellType;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;
    import jxl.write.WritableWorkbook;
    public class CopyExcel {
         private String inputFile;
         public void setInputFile(String inputFile) {
              this.inputFile = inputFile;
         public void copy() throws IOException  {
              File inputWorkbook = new File(inputFile);
              Workbook w;
                    try{
                        System.out.println("Before w= Workbook.getWorkbook(inputWorkbook);  ");
              w= Workbook.getWorkbook(inputWorkbook);
                     System.out.println("After w= Workbook.getWorkbook(inputWorkbook);  ");
              WritableWorkbook copy=Workbook.createWorkbook(new File("CopyPan.xls"), w);
                    copy.write();
                    copy.close();
                    }catch(Exception e){}
    /*          try {
                   w = Workbook.getWorkbook(inputWorkbook);
                   // Get the first sheet
                   Sheet sheet = w.getSheet(0);
                   // Loop over first 10 column and lines
                        for (int i = 1; i < 6; i++) {
                             Cell cell = sheet.getCell(0, i);
                             //CellType type = cell.getType();
                             //if (cell.getType() == CellType.LABEL) {
                                  //System.out.println("I got a label "
                                       //     + cell.getContents());
                             //if (cell.getType() == CellType.NUMBER) {
                                  //System.out.println("I got a number "
                                            //+ cell.getContents());
                                                    System.out.println(cell.getContents());
              } catch (BiffException e) {
                   e.printStackTrace();
         public static  String copyMain(String args) throws IOException {
              String str=args;
              CopyExcel test = new CopyExcel();
              test.setInputFile(args);
              test.copy();
                    return "Success";
    }I have set the "CLASSPATH" environment variables in "user variables for administrator" as follows,
    .;%SYSTEM%;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\bin;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_11\lib\jxl-2.6.jar Also I have tried editing the startup MS-dos batch file as folows....
    set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_11
    set CLASSPATH=.;%SYSTEM%;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\bin;C:\Program Files\Apache Software Foundation\apache-tomcat-7.0.4\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_11\lib\jxl-2.6.jar
    @echo off
    rem Licensed to the Apache Software Foundation (ASF) under one or more
    rem contributor license agreements.  See the NOTICE file distributed with
    rem this work for additional information regarding copyright ownership.
    rem The ASF licenses thi..........But the problem remained...........
    Plz. help me.
    Thank u in advance for any help.

  • I don't find my JdbcOdbcDriver.jar

    Hi,
    With java web start, I have a error message(The driver: sun.jdbc.odbc.JdbcOdbcDriver could not be loaded. This could be a problem with the driver itself, or that the driver is not found on the classpath)
    I can't consult my frames where there are the queries.
    I have to put in my .jnlp the good JdbcOdbcDriver.jar.
    My database is DB2.
    Anyone can help me please?
    Thanks in advance

    I have still the same error message(The driver: sun.jdbc.odbc.JdbcOdbcDriver could not be loaded. This could be a problem with the driver itself, or that the driver is not found on the classpath.)
    I have added the classes.zip int the .jnlp.
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://cff125gyu:8082/webmanip" href="ManipAS400.jnlp">
    <information>
    <title>ManipAS400</title>
    <vendor>Tarkett Sommer</vendor>
    <homepage href="ManipAS400.html" />
    <description>Manipulation de tables1</description>
    </information>
    <resources>
    <j2se version="1.3+" />
    <jar href="ManipulationLigneAS400.jar" />
    <jar href="classes12.zip" />
    </resources>
    <application-desc main-class="manipulationligneas400.Application1" />
    </jnlp>
    classes12.zip is for the oracle database, I think?
    With the DB2 database, is it too classes12.zip ?

  • File objects in jar file

    Hi!
    Is their some kind of way one can use File objects in a jar file plz? I have a project which is complete and working well on the IDE but now that I have jarred it, i've come to realize that apparently file objects do not relate well with .jar files. The problem is that the program makes a lot of file manipulations and changing everything to getResource, InputStream etc would be very lengthy. So there's absolutely no way in which one can use File objects in jar files?
    Any help would be very much appreciated!
    Thanks and regards,
    Krt_Malta

    You can use the java.net.JarURLConnection class (use file:/// when creating the URL) to get a URL to a jar entry, create a URI from the URL, and then create a File object on the URI.
    Or use java.util.jar.JarFile methods and its associated classes to get jar entry contents.
    While you can use these approaches to create File objects from a jar, they are not any easier than what's already been mentioned.
    And all you can do is read or delete a jar - jar entries can't be rewritten.

  • Opening a jar file using labview

    Hi,
    I want my labview program to open a java based jar file on my computer after some processing steps...there is no manipulation of the jar file to be done..It just needs to be opened...Anyone has any answers?????

    Hi Prathiksha,
    As GuenterMueller said, this forum subgroup is dedicated to Machine vision queries and not related to general software queries. Please post your query in Labview Forum or some other appropriate location.
    Coming to ur problem, infact even i've seen that java interfacing all those are really compicated and am afraid i dnt know about that.
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Protect files from manipulation

    Hi,
    I have a question about JAR deployment. In my program, I have a lot of properties, and I want to externalize them (e.g. in an XML file, or similar) to make manipulation for the rest of the team easier.
    However, in the final state, I don't want the customer to access this data.
    How can I protect my data from manipulation? Can I forbid the decompression of the JAR file, and still allow execution of it? Or is there another way to achieve what I want?

    It's all about making it harder. I know that. People that post these questions don't always know that. This OP seems to know that, but the way he talked about this case left me unsure whether he realized it just makes it very hard, or thought it actually made it impossible.
    It's nonesensical to
    talk of "do this, but it's still possible to get
    around ..." in terms of security implemetation. No, it's not. It's worth driving the point home to people that think that encrypted classes, etc. will make their Java code impossible to reverse engineer. It's worth clearing up that little misconception.
    Yes,
    it's possible, but yes it's also now harder then it
    used to be. Keep adding these things on and it
    becomes harder and harder and harder. You don't get
    anywhere if you just kill the whole idea from the
    start.I'm not killing the whole idea from the start. I'm merely attempting to make sure the OP (and anyone else who happens to be perusing this thread) is clear that it's only hard, not impossible. Like I said, I think this OP gets that, but it doesn't hurt to be sure.

Maybe you are looking for