'protect' my Java Code

Hi friends, my question is simple:
1) How to protect the java Desktop code, you know if i redistribute the .class files, it can be decompiled and get the java code, i want to do similar to Visual Basic, that generate a .EXE file and is hard hard decompile it, is possible? 
2) How to protect the JSP code,  you know Netbeans Generate a .war file, but Tomcat deploy it on the server, right? but in the server the user can see the code, if i add a servlet, it generate a .class file right? again exist tools for decompile .class files, bad bad, in PHP exist a way for encrypt the php code with Zend. exist similar for JSP?
Thanks

1) How to protect the java Desktop code, you know if i redistribute the .class files, it can be decompiled and get the java code, i want to do similar to Visual Basic, that generate a .EXE file and is hard hard decompile it, is possible?
2) How to protect the JSP code,  you know Netbeans Generate a .war file, but Tomcat deploy it on the server, right? but in the server the user can see the code, if i add a servlet, it generate a .class file right? again exist tools for decompile .class files, bad bad, in PHP exist a way for encrypt the php code with Zend. exist similar for JSP?
I suggest that before you pursue any solution you make sure you REALLY have something that needs protected to begin with. There is a LOT of software out there from MAJOR companies who haven't bothered to try to 'protect' their code except through license agreements and legal channels.
Even Oracle's FREE to download Sql Developer tool has basically no protection from 'decompiling' and it has a lot of sophisticated functionality in it.
The most reasonable thing to do, IMHO, if you really need to do anything is to obfuscate the code. Here is a link to a free-ware/shareware application that is pretty popular.
ProGuard
Keep in mind that ANYTHING you do will further complicate your own production and distribution of the product as well as make upgrades and bug fixes MUCH harder.

Similar Messages

  • How to Configure the Datasource In JNDI and access it through Java Code

    I have declared under web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    Under Jrun-resource.xml
    <data-source>
                <dbname>xxxxxxx</dbname>
                <driver>macromedia.jdbc.sqlserver.SQLServerDriver</driver>
                <url>jdbc:macromedia:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxxxxx</url>
                <username>xxxxxxxx</username>
                <password>xxxxxxxxx</password>
                <encrypted>false</encrypted>
                <encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
                <native-results>true</native-results>
                <remove-on-exceptions>true</remove-on-exceptions>
                <pool-statements>false</pool-statements>
                <initial-connections>1</initial-connections>
                <connection-timeout>1200</connection-timeout>
                <transaction-timeout>20</transaction-timeout>
                <cache-enabled>false</cache-enabled>
                <cache-size>5</cache-size>
                <cache-refresh-interval>30</cache-refresh-interval>
                <jndi-name>MSDataSource</jndi-name>
                <poolname>Pool</poolname>
                <minimum-size>0</minimum-size>
                <maximum-size>2147483647</maximum-size>
                <user-timeout>20</user-timeout>
                <skimmer-frequency>420</skimmer-frequency>
                <shrink-by>5</shrink-by>
                <maximum-soft>true</maximum-soft>
                <debugging>false</debugging>
                <disable-pooling>false</disable-pooling>
                <isolation-level>READ_UNCOMMITTED</isolation-level>
                <description/>
         </data-source>
    Under jrun-web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <jndi-name>MSDataSource</jndi-name>
    </resource-ref>  
    Java Code
    String dsndb="java:comp/env/MSDataSource";
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,"jrun.naming.JRunContextFactory");
    p.put(Context.PROVIDER_URL, "localhost:2932");
    InitialContext context=new InitialContext(p);
    System.out.println(context.getEnvironment());
    DataSource ds=(DataSource)context.lookup(dsndb);
    ds.getConnection();
    System.out.println(ds.getConnection().toString());
    Error is
    {java.naming.provider.url=localhost:2932, java.naming.factory.initial=jrun.naming.JRunContextFactory}
    Exception in thread "main" javax.naming.NameNotFoundException: No such binding: MSDataSource
        at jrun.naming.ContextManager.getBinding(ContextManager.java:680)
        at jrun.naming.ContextManager.getBinding(ContextManager.java:686)
        at jrun.naming.ContextManager.getObject(ContextManager.java:690)
        at jrun.naming.ContextManager.lookup(ContextManager.java:463)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:501)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:644)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:470)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at Controller.DBManager.getConnection(DBManager.java:29)
        at Controller.DBManager.main(DBManager.java:42)
    Please help me .
    Thanks in advance

    Also, try to log the username/password in your authenticator, just to be sure that credentials changeGood piece of advice, michael. Worth of it. When I changed the credentials manually, it worked correctly,but from the application, when I logout from 'a', 'a' and log in to 'b', 'b', I got a valuable information.
    I tried debugging like given below for checking from the application.
    class MyAuthenticator extends Authenticator {
        protected PasswordAuthentication getPasswordAuthentication() {
             System.out.println("userrrrrrrrr"+UtilsHTTPS.username);
             System.out.println("pwdddddddddd"+UtilsHTTPS.password);
      .........................................The information I got while debugging from the application was, the username and password does not get printed. It implies that, Authenticator.setDefault(new MyAuthenticator()); does not work as desired ie; even on calling new MyAuthenticator(), it does not get inside the MyAuthenticator class.
    Why does this happen? What is the solution for this?

  • Proplem: Access HTMLB controls from java code

    Hi,
    I am new to iView development for EP6. So my problem should be easy to solve (for you ).
    I created in the NW Dev Studio a JSP DynPage.
    The following files were created or edited:
    1.     JSP file (created)
    2.     java file (created)
    3.     portalapp.xml (edited)
    In order to make the page running (proccessing) I changed the following things:
    1.     JSP file – Add taglib reference to HTMLB-class
    2.     portalapp.xml – Remove the „native“ property so the JSP file will not be accessed directly.
    Now I want to do the following:
    On the JSP page I placed severeal HTMLB controls (textViews).
    From the java code I try to access these controls in the „doProcessBeforeOutput“ method and change/set values.
    But I get all the time a null-Exception.
    Code (JSP)
    <%-- mcmsprovider.jsp --%>
    <%@ taglib uri= "tagLib" prefix="hbj" %>
    <hbj:content id="cntMcmsProvider" >
      <hbj:page title="MCMS Provider Dynpage">
       <hbj:form id="frmMcmsProvider" >
                 <hbj:textView id="tvwScript" encode="false"></hbj:textView>
                 <hbj:textView id="tvwStyle" encode="false"></hbj:textView>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    Code (JAVA):
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
           TextView tvw = (TextView) this.getComponentByName("tvwStyle");
           tvw.setText("Here the dynamic text");
    I also tried to add raw text to the form but also null excpetion:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
           Form frmCurrent = (Form) this.getForm();
           frmCurrent.addRawText("<h3>This comes from here</h3>");
    My goal is to dynamically add controls to the form, but until now I think it will be a dream:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
      Form form = (Form)this.getForm();
           TextView tvw  = new TextView("tvwDynamic");
           tvw.setText("Here the dynamic control");
           form.addComponent(tvw);
    The normal page processing runs:
    public void doProcessBeforeOutput() throws PageException {
           this.setJspName("mcmsprovider.jsp");
    Any help is greatly appreciated.

    Eike
    Here is the example straight from the PDK documentation. This should help you a little
    UsingAbstractPortalComponentWithHTMLB.java
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.DataType;
    import com.sapportals.htmlb.enum.GroupDesign;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class UsingAbstractPortalComponentWithHTMLB extends AbstractPortalComponent {
        //Fill in your output for "normal" content creation mode here
        protected void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
            IPageContext myContext = PageContextFactory.createPageContext(request, response);
            if (myContext == null) {
                System.out.println("htmlb service did not start up as expected.");
            Form myForm = myContext.createFormDocument("First Experiment");
            Event lastEvent = myContext.getCurrentEvent();
            Group myGroup = new Group();
            myGroup.setWidth("350");
            myGroup.setTitle("First Experiment");
            myGroup.setDesign(GroupDesign.SAPCOLOR);
            myForm.addComponent(myGroup);
            GridLayout gl = new GridLayout();
            myGroup.addComponent(gl);
            if ((lastEvent != null) && (lastEvent.getComponentName().equals("submit"))) {
                String name = myContext.getDataForComponentId("USER_NAME").toString();
                TextView label = new TextView("Hi, " + name);
                gl.addComponent(1, 1, label);
                Button myButton = new Button("goback", "Go back");
                myButton.setOnClick("goBack"); // ignored anyway
                gl.addComponent(2, 1, myButton);
            } else {
                TextView label = new TextView("What's your name?");
                gl.addComponent(1, 1, label);
                InputField inf = new InputField("USER_NAME");
                inf.setType(DataType.STRING);
                gl.addComponent(1, 2, inf);
                Button myButton = new Button("submit", "Tell");
                myButton.setOnClick("submit");
                gl.addComponent(2, 2, myButton);
            myContext.render();

  • Business connector  and BAPI ,java code

    Guy's
    we are having development project based on <b>Business
    connector and bapi</b> for sales order creation,we are
    going for function module /TECCOM/SALESORDER_SIMULATE
    for Availability request ,i am not aware of using business
    connector and bapi before,they are going for some java code,now i have to create java code and use this particualr BAPI,pls if somebody already worked on such issue,then help me with some material which will guide
    me and help me in finishing this task easily,
    <b>mail me at [email protected]</b>

    This is a very usefull link:
    http://www.henrikfrank.dk/abapexamples/Java/

  • How to protect JSP source code on the Server Side ?

    I am new on JSP. I Already know about various Web and Desktop technologies but is the first time on JSP. I know ASP for example.
    Well, about .NET platform, it protects my source code on the server, the source code is compiled and on the server, only the compiled file are installed, my source code stay with me...
    About JSP, how it works about ? Is possible to hide my source code too ? What the technique to hide the codes ? I need to prevent access to my source codes...
    Roberto

    roberto.novakosky wrote:
    About .exe files, do you know if a java class is more easy or dificult to do reverse engineering ?Depends on who your enemy is. If it's for example a hacker with a lot of C knowledge but zero of Java knowledge, reverse engineering .exe would be easier than .class. If one was interested, one would always take time to learn how to decompile the one or other. Making files secure is a waste of time. It's always "hackable".
    If there was a proof of concept, no one major software vendor would have had so much problems with piracy and cracks/keygens. Think about it once again. It's simply impossible. Just have a clear EULA and actually make work of it whenever you discovers if someone breaks your EULA.
    I was thinking about, the .JSP can be converted to servlet .java, and converted to .class, this way hide the source code.Once again, one could still decompile it (or reverse engineer, so you call).

  • Protecting the source code

    I heard about the possibilty of decompiling the java code and getting back the source code, is this flaw specific to java or is it common among all programming langauges?
    how is it possible to protect the source code? and how expensive is the solution?
    thank you

    This is not a flaw!
    Java is compiled on the byte level not bit level. This is so because the same class can run on Windows, Solaris, Linux and Unix. This makes the execution a little bit slower and easier to decompile but a small price to pay for cross platform compatibilty.

  • Stoping System Clock using Java code.

    Is it possible to do so if yes then some code idea for
    Stoping System Clock using Java code.
    [email protected]

    The system clock is controlled from the BIOS, and as such, I don't think even windoze can stop it, though it can be continually reset. I don't believe that Java provides a sufficiently low level of control to set the system clock, although you could use a native method to accomplish the task.
    Why would you want to do such a thing?

  • Interpreting JSP code in Java code

    Hi,
         I am writing a scheduler to generate emails based on certain events.
    The email body constructed using HTML. I was constructing the HTML string
    for the body using string concats. Its quickly becoming untenable to
    maintain the code whenever I have to make changes to email body.
    I thinking of using JSP based templates. [ I have access to all the tomcat jar files in my program]
         I have following question in this context:
         Can I parse/compile the JSP file in the java code and invoke the
    resultant class with my input variable's) to get a output stream?
    E.g.: Lets say I have a JSP template as shown below:
    <HTML>
    <TABLE >
    <TR>
    <TD>Name:</TD>
    <TD>Telephone number:</TD>
    </TR>
    <%
    for ( int i = 0; i < input.size(); i++)
    %>
    <TR>
    <TD>
    <%=(Contacts)input.getName()%>
    </TD>
    <TD>
    <%=(Contacts)input[i].getTelephonenumber()%>
    </TD>
    </TR>
    <%
    %>
    </TABLE >
    </HTML>
    I want to execute the JSP with some input in my java method and get the resultant HTML string.
    Is its possible to do this? Or is there a better way of doing this?
    Thanks
    mg

    Sorry didn't read that properly.
    If you are sending emails using javamail, you can specify a URL datasource:
    Can't promise this code will work out of the box, but it may give a couple of ideas...
    I was sending an attachment with this mail, and I've chopped that bit out.
    // Create message
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]"));
    InternetAddress addr = new InternetAddress();
    message.addRecipients(Message.RecipientType.TO, email);
    message.setSubject(mailSubject);
    Multipart multipart = new MimeMultipart();
    // The important part - reading the body of the message from a URL.
    URL url = new URL("http://urlToGenerateTheEmailAutomatically");
    DataSource source = new URLDataSource(url);
    BodyPart  messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler(source));
    multipart.addBodyPart(messageBodyPart);
    // send message.
    message.setContent(multipart);
    transport.sendMessage(message, message.getAllRecipients());

  • Playing .swf files in Java code

    How can is run a .swf in Java code. And change the .swf at runtime. I tried Using the JFlashPlayer api. but it does not work properly.
    I have a set of different .swf files. I need to run these files using a next/ previous button .... which changes the .swf files at runtime for the FlashPlayer object.....
    Please provide me guidance.......very urget.....
    you can mail me on [email protected]
    REgards
    gp
    Message was edited by:
    GurujiForAll

    How can is run a .swf in Java code. And change the
    .swf at runtime. I tried Using the JFlashPlayer api.
    but it does not work properly.> Then you should contact the vendor for support which you are entitled too after paying the license fee. Unless of course that "not paying the license fee" is what "does not work properly" actually means.

  • How do I trigger an Oracle report through Java Code?

    Hello,
    I am new to reports. Is there any way to trigger a report through java code - I know there is an OS command to trigger a report automatically. Has anybody done this through a high level PL?
    Amit

    We are in a similar situation. If you receive any answers can you forward the same to [email protected]

  • Problems with backing Java Code

    Earlier I manually deleted the processChange event handler method for a textfield from the backing java code. As I had no plans to use that event handler. Now my page abends with a message stating that the process chnage method is not available. I tried to add via the event handler for the textbox using the GUI but it does not add the process change event handler method. Using an another process change method as a model I manually entered the code to handle process change for the text bos. Now I am getting an internal server exception - Null in one of the parameters. PLEASE HELP. What are my options - Delete and re-create the entire page

    Hi,
    Yes I am using the recommeded code: The Text field generating the null exception is addDataSourceTF. Whenever we click on the addDataSourceBTN we get an Internal exception.
    Thanks very much for looking into this problem. Any advice will be greatly appreciated.
    <h:panelGrid binding="#{MainPage.gridPanel1}" cellpadding="3" cellspacing="2" columnClasses="" id="gridPanel1" style="background-color: rgb(204, 255, 204); left: 48px; top: 312px; position: absolute">
    <h:inputText binding="#{MainPage.addDataSourceTF}" id="addDataSourceTF" style="font-family: Arial,Helvetica,sans-serif"
    validator="#{MainPage.addDataSourceTF_validate}" valueChangeListener="#{MainPage.addDataSourceTF_processValueChange}"/>
    <h:commandButton action="#{MainPage.addDataSourceBTN_action}" binding="#{MainPage.addDataSourceBTN}" id="addDataSourceBTN"
    image="resources/button32.jpg" value="Add Data Source"/>
    <h:selectOneMenu binding="#{MainPage.deleteDataSourceDD}" id="deleteDataSourceDD" immediate="true" onchange="this.form.submit();"
    style="height: 23px; width: 164px" valueChangeListener="#{MainPage.deleteDataSourceDD_processValueChange}">
    <f:selectItems binding="#{MainPage.dropdown1SelectItems}" id="dropdown1SelectItems" value="#{MainPage.database_infoRowSet.selectItems['DB_SRC,DB_SRC']}"/>
    </h:selectOneMenu>
    <h:commandButton action="#{MainPage.deleteDataSourceBTN_action}" binding="#{MainPage.deleteDataSourceBTN}" id="deleteDataSourceBTN"
    image="resources/delete.jpg" value="Submit"/>
    </h:panelGrid>
    Backing Java Code:
    * MainPage.java
    * Created on December 15, 2004, 1:45 AM
    * Copyright adear1
    package dissertation;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import com.sun.jsfcl.data.*;
    import javax.faces.component.*;
    import javax.faces.event.*;
    import com.sun.sql.rowset.*;
    import javax.faces.context.FacesContext;
    import javax.faces.application.FacesMessage;
    import javax.faces.convert.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    import java.lang.*;
    import javax.faces.context.*;
    public class MainPage extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
    private int __placeholder;
    private HtmlForm form1 = new HtmlForm();
    public HtmlForm getForm1() {
    return form1;
    public void setForm1(HtmlForm hf) {
    this.form1 = hf;
    private HtmlCommandButton addDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getAddDataSourceBTN() {
    return addDataSourceBTN;
    public void setAddDataSourceBTN(HtmlCommandButton hcb) {
    this.addDataSourceBTN = hcb;
    private HtmlCommandButton searchDataBTN = new HtmlCommandButton();
    public HtmlCommandButton getSearchDataBTN() {
    return searchDataBTN;
    public void setSearchDataBTN(HtmlCommandButton hcb) {
    this.searchDataBTN = hcb;
    private HtmlCommandButton scrubbingRulesBTN = new HtmlCommandButton();
    public HtmlCommandButton getScrubbingRulesBTN() {
    return scrubbingRulesBTN;
    public void setScrubbingRulesBTN(HtmlCommandButton hcb) {
    this.scrubbingRulesBTN = hcb;
    private HtmlCommandButton scrubDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getScrubDataSourceBTN() {
    return scrubDataSourceBTN;
    public void setScrubDataSourceBTN(HtmlCommandButton hcb) {
    this.scrubDataSourceBTN = hcb;
    private HtmlCommandButton uploadDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getUploadDataSourceBTN() {
    return uploadDataSourceBTN;
    public void setUploadDataSourceBTN(HtmlCommandButton hcb) {
    this.uploadDataSourceBTN = hcb;
    private HtmlCommandButton deleteDataSourceBTN = new HtmlCommandButton();
    public HtmlCommandButton getDeleteDataSourceBTN() {
    return deleteDataSourceBTN;
    public void setDeleteDataSourceBTN(HtmlCommandButton hcb) {
    this.deleteDataSourceBTN = hcb;
    private HtmlInputText addDataSourceTF = new HtmlInputText();
    public HtmlInputText getAddDataSourceTF() {
    return addDataSourceTF;
    public void setAddDataSourceTF(HtmlInputText hit) {
    this.addDataSourceTF = hit;
    private HtmlSelectOneMenu deleteDataSourceDD = new HtmlSelectOneMenu();
    public HtmlSelectOneMenu getDeleteDataSourceDD() {
    return deleteDataSourceDD;
    public void setDeleteDataSourceDD(HtmlSelectOneMenu hsom) {
    this.deleteDataSourceDD = hsom;
    private DefaultSelectItemsArray dropdown1DefaultItems = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getDropdown1DefaultItems() {
    return dropdown1DefaultItems;
    public void setDropdown1DefaultItems(DefaultSelectItemsArray dsia) {
    this.dropdown1DefaultItems = dsia;
    private UISelectItems dropdown1SelectItems = new UISelectItems();
    public UISelectItems getDropdown1SelectItems() {
    return dropdown1SelectItems;
    public void setDropdown1SelectItems(UISelectItems uisi) {
    this.dropdown1SelectItems = uisi;
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
    public HtmlPanelGrid getGridPanel1() {
    return gridPanel1;
    public void setGridPanel1(HtmlPanelGrid hpg) {
    this.gridPanel1 = hpg;
    private HtmlPanelGrid gridPanel2 = new HtmlPanelGrid();
    public HtmlPanelGrid getGridPanel2() {
    return gridPanel2;
    public void setGridPanel2(HtmlPanelGrid hpg) {
    this.gridPanel2 = hpg;
    private HtmlOutputText welcomeOT = new HtmlOutputText();
    public HtmlOutputText getWelcomeOT() {
    return welcomeOT;
    public void setWelcomeOT(HtmlOutputText hot) {
    this.welcomeOT = hot;
    private JdbcRowSetXImpl database_infoRowSet = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getDatabase_infoRowSet() {
    return database_infoRowSet;
    public void setDatabase_infoRowSet(JdbcRowSetXImpl jrsxi) {
    this.database_infoRowSet = jrsxi;
    private DefaultSelectItemsArray listbox1DefaultItems1 = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getListbox1DefaultItems1() {
    return listbox1DefaultItems1;
    public void setListbox1DefaultItems1(DefaultSelectItemsArray dsia) {
    this.listbox1DefaultItems1 = dsia;
    private HtmlSelectOneListbox dataSourceLB = new HtmlSelectOneListbox();
    public HtmlSelectOneListbox getDataSourceLB() {
    return dataSourceLB;
    public void setDataSourceLB(HtmlSelectOneListbox hsol) {
    this.dataSourceLB = hsol;
    private DefaultSelectItemsArray listbox1DefaultItems2 = new DefaultSelectItemsArray();
    public DefaultSelectItemsArray getListbox1DefaultItems2() {
    return listbox1DefaultItems2;
    public void setListbox1DefaultItems2(DefaultSelectItemsArray dsia) {
    this.listbox1DefaultItems2 = dsia;
    private UISelectItems listbox1SelectItems = new UISelectItems();
    public UISelectItems getListbox1SelectItems() {
    return listbox1SelectItems;
    public void setListbox1SelectItems(UISelectItems uisi) {
    this.listbox1SelectItems = uisi;
    private JdbcRowSetXImpl database_infoRowSet1 = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getDatabase_infoRowSet1() {
    return database_infoRowSet1;
    public void setDatabase_infoRowSet1(JdbcRowSetXImpl jrsxi) {
    this.database_infoRowSet1 = jrsxi;
    private JdbcRowSetXImpl user_tableRowSet = new JdbcRowSetXImpl();
    public JdbcRowSetXImpl getUser_tableRowSet() {
    return user_tableRowSet;
    public void setUser_tableRowSet(JdbcRowSetXImpl jrsxi) {
    this.user_tableRowSet = jrsxi;
    private HtmlMessages messageList1 = new HtmlMessages();
    public HtmlMessages getMessageList1() {
    return messageList1;
    public void setMessageList1(HtmlMessages hm) {
    this.messageList1 = hm;
    private HtmlOutputText welcomeOT1 = new HtmlOutputText();
    public HtmlOutputText getWelcomeOT1() {
    return welcomeOT1;
    public void setWelcomeOT1(HtmlOutputText hot) {
    this.welcomeOT1 = hot;
    // </editor-fold>
    public MainPage() {
    // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
    try {
    database_infoRowSet.setDataSourceName("java:comp/env/jdbc/mySQL");
    database_infoRowSet.setCommand("SELECT ALL database_info.DB_SRC, database_info.USER_ID FROM database_info WHERE database_info.USER_ID = ?");
    database_infoRowSet1.setDataSourceName("java:comp/env/jdbc/mySQL");
    database_infoRowSet1.setCommand("SELECT ALL database_info.DB_SRC, database_info.DB_URL, database_info.DB_SCHEMA, database_info.DB_TYPE, database_info.USER_ID FROM database_info WHERE database_info.USER_ID = ?");
    user_tableRowSet.setDataSourceName("java:comp/env/jdbc/mySQL");
    user_tableRowSet.setCommand("SELECT * FROM user_table");
    } catch (Exception e) {
    log("MainPage Initialization Failure", e);
    throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
    // </editor-fold>
    // Additional user provided initialization code
    try{
    database_infoRowSet.setString(1, getSessionBean1().getSbUserID());
    database_infoRowSet1.setString(1, getSessionBean1().getSbUserID());
    database_infoRowSet.execute();
    database_infoRowSet1.execute();
    database_infoRowSet1.first();
    if (database_infoRowSet.next()) {
    // If no row found then make the following button's as readonly
    database_infoRowSet.first();
    else {
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage(
    "Please Add Data Source to Begin Processing", ""));
    searchDataBTN.setDisabled(true);
    scrubbingRulesBTN.setDisabled(true);
    scrubDataSourceBTN.setDisabled(true);
    uploadDataSourceBTN.setDisabled(true);
    catch (Exception ex){
    log("Error in initializing database_info Row Set", ex);
    protected dissertation.ApplicationBean1 getApplicationBean1() {
    return (dissertation.ApplicationBean1)getBean("ApplicationBean1");
    protected dissertation.SessionBean1 getSessionBean1() {
    return (dissertation.SessionBean1)getBean("SessionBean1");
    * Bean cleanup.
    protected void afterRenderResponse() {
    user_tableRowSet.close();
    database_infoRowSet1.close();
    database_infoRowSet.close();
    public String searchDataBTN_action() {
    // TODO Following code was replaced by static navigation
    // TODO Replace with your code
    //if no value selected then we prompt them to select a row
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "searchcriticaldata";
    public String scrubbingRulesBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "definecolumnrules";
    public String scrubDataSourceBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "scrubdata";
    public String uploadDataSourceBTN_action() {
    // TODO Replace with your code
    if (dataSourceLB.getValue().equals("")||dataSourceLB.getValue()== null){
    // return error msg to select a row before continuing
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage("Please select a data source to process", ""));
    return null;
    else {
    // call method to retrieve the db_schema from the
    getDbDetails();
    getDbDriver();
    return "uploaddata";
    public String addDataSourceBTN_action() {
    // TODO Following code was replaced by static navigation
    if ( false) {
    // TODO Replace with your code
    if (addDataSourceTF.getValue().equals("")){
    FacesContext fc =
    javax.faces.context.FacesContext.getCurrentInstance();
    fc.addMessage(null, new FacesMessage(
    "Please specify Data Source to Add", ""));
    return null;
    else {
    String woSpaces = ((String)addDataSourceTF.getValue()).replace(' ', '_');
    getSessionBean1().setSbDataSrc(woSpaces);
    return "adddatasrc";
    return "adddatasrc";
    public void getDbDetails(){
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Select db_src, db_url, db_schema, db_type user_id, src_password from database_info where db_src=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, (String) dataSourceLB.getValue());
    ResultSet rs = pstmt.executeQuery();
    if (rs.next()){
    getSessionBean1().setSbDataSrc(rs.getString("db_src"));
    getSessionBean1().setSbDb_Schema(rs.getString("db_schema"));
    getSessionBean1().setSbDb_Type(rs.getString("db_type"));
    getSessionBean1().setSbDb_Userid(rs.getString("user_id"));
    getSessionBean1().setSbDb_Password(rs.getString("src_password"));
    else
    java.lang.System.out.println("DB_Schema not found for db_src " +
    (String) dataSourceLB.getValue());
    rs.close();
    pstmt.close();
    conn.close();
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    public void getDbDriver(){
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Select db_driver from database_type where db_type=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, getSessionBean1().getSbDb_Type());
    ResultSet rs = pstmt.executeQuery();
    if (rs.next()){
    getSessionBean1().setSbDb_Driver(rs.getString("db_driver"));
    else
    java.lang.System.out.println("DB_Driver not found for db_src " +
    (String) dataSourceLB.getValue());
    rs.close();
    pstmt.close();
    conn.close();
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    public String deleteDataSourceBTN_action() {
    // TODO Replace with your code
    try {
    Context ctx = new InitialContext();
    if (ctx == null) throw new NamingException("No Initial Context");
    DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mySQL");
    if (ds == null) throw new NamingException("No Data Source mySQL");
    Connection conn = ds.getConnection();
    if (conn == null)
    throw new SQLException("Unable to establish connection");
    String sql = "Delete from database_info where db_src=?";
    PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, (String) deleteDataSourceDD.getValue());
    pstmt.executeUpdate();
    pstmt.close();
    conn.close();
    return "success";
    catch (SQLException ex) {
    java.lang.System.out.println("\n ----- SQL Exception caught ------\n");
    while (ex !=null){
    java.lang.System.out.println("Message: " + ex.getMessage());
    java.lang.System.out.println("SQLState: " + ex.getSQLState());
    java.lang.System.out.println("ErrorCode: " + ex.getErrorCode());
    ex = ex.getNextException();
    java.lang.System.out.println("");
    return "failure";
    catch (NamingException e){
    java.lang.System.out.println("messge unable to establish context in changepassword.jsp");
    return "failure";
    public void addDataSourceTF_processValueChange(ValueChangeEvent vce) {
    // TODO Replace with your code
    public void deleteDataSourceDD_processValueChange(ValueChangeEvent vce) {
    // TODO Replace with your code
    public void addDataSourceTF_validate(FacesContext fc, UIComponent uic, Object o) {
    // TODO Replace with your code
    }

  • Execute java code taken from a properties file

    I have a requirement to store some java code in the Properties file & use the code inside the program later. Is there a way I can execute this code after I get it from the .properties file which is retrieved using the ResourceBundle?
    Example:
    File: system.properties
    Item_list=blocksBean.menu(QueryValue,request.getContextPath())
    Inside my Java program I'm using this..
    theBody=codesBean.replaceAll(theBody, "%%menu%%",ResourceBundle.getBundle("system").getString("Item_list"), true);
    instead of
    theBody=codesBean.replaceAll(theBody, "%%menu%%",blocksBean.menu(QueryValue,request.getContextPath()), true);
    This doesn't work because ResourceBundle.getBundle("... returns the value.. which is a string "blocksBean.menu(QueryValue,request.getContextPath())". But what I need is it has to be executed..
    blocksBean.menu() returns a string value of html code fetched from the dartabase.
    Is there a way I can execute blocksBean.menu() which is retrieved from the .properties file.. If anyone has done it / have an idea on this.. please e-mail me [email protected]
    I need something like an eval() in javaScript..
    Thanks in advance
    -ashok

    These boys might have something that will help you:
    http://www.beanshell.org/
    Good luck
    Lee

  • Is java Code is Safe.

    I have used an IDE, named Gell, which can show the Java Code of a .class file. So the question is "IS JAVA SAFE" since we can see the code and change it and recompile. Is there any other tool like this which can do so.

    "Is Java safe?" is a completely meaningless question. You have to qualify exactly what you mean by "safe."
    Also, any code can be reverse-engineered. The fact the Java programs' default (but definitely NOT only) deployment paradigm is somewhat easier to decompile than native executables is less of a security detriment and more of a support benefit.
    The only bullet-proof technological solution to security is to not distribute your program in the first place. Make all the super-secret stuff execute only on a remote server that is a black box. The rest of the actual significant protection that you can get comes from the law, not from technology.
    Before you worry about how "safe" Java is, you must have concrete answers to questions like: Just how revolutionary and unique is your code anyway? How many people will really want it, AND will be unethical enough to steal it? How much actual financial damage will you suffer from that? How much are you willing to pay (in man hours, complexity, time-to-market, maintenance costs, etc.) to prevent that?
    If Java is the most appopriate technology for your needs, then use it. If you really have security issues, they can be addressed separately.

  • Invalid Java code from oracg

    I'm having a problem with oracg generating invalid Java code using XDK for Java 9.2.0.5.0 on Solaris 8.
    Specifically, oracg generates invalid Type names for elements that have both attributes and complexTypes; at least, that's where I'm having problems with it.
    I've included my test case in this posting. I have defined the following structure in test.xsd:
    <test lang="en">
    <table border="0">
    <tr>
    <td>blah</td>
    </tr>
    </table>
    </test>
    Then, oracg generates an add method for TestType as:
    public void addTable(TestType.Lang.Table thetable)
    It doesn't seem to realize that Lang is an attribute, and
    it puts it in the type path. This happens throughout the TestType.java file.
    Please advise.
    Thanks,
    -Darren
    P.S. I'm using "oracle-xdk-9.2.0.5.0/bin/oracg -schema test.xsd -outputDir src -package test"
    ========
    test.xsd
    ========
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://xmlns/test" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns/test" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
    <xs:complexType name="testType" mixed="false">
    <xs:choice maxOccurs="unbounded">
    <xs:element name="table" nillable="false">
    <xs:complexType mixed="false">
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="tr" nillable="false">
    <xs:complexType mixed="false">
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="td" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    <xs:attribute name="border" type="xs:nonNegativeInteger" use="optional" default="1"/>
    <xs:attribute name="cellspacing" type="xs:nonNegativeInteger" use="optional" default="2"/>
    <xs:attribute name="cellpadding" type="xs:nonNegativeInteger" use="optional" default="2"/>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    <xs:attribute name="lang" use="optional" default="en">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:minLength value="1"/>
    <xs:maxLength value="10"/>
    <xs:enumeration value="en"/>
    <xs:enumeration value="es"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:complexType>
    <xs:element name="test" type="testType" nillable="false"/>
    </xs:schema>
    =============
    TestType.java
    =============
    /* DO NOT EDIT THIS FILE - it is machine-generated */
    /* File: TestType.java - generated by XML Class Generator version 2.0.0 at Mon Jun 30 13:26:33 PDT 2003 */
    package test.types;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import oracle.xml.classgen.CGXSDElement;
    import oracle.xml.classgen.InvalidContentException;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class TestType extends CGXSDElement
    static final String name = "testType";
    static final String namespace = "http://xmlns/test";
    protected TestType.Lang alang;
    public void setLang(TestType.Lang thelang)
    throws IllegalArgumentException
    this.alang = thelang;
    super.addAttribute("lang" , thelang.getNodeValue());
    public static class Lang extends CGXSDElement
    public Lang(XSDDataValue elemValue)
    throws InvalidContentException
    try
    Hashtable h = XSDSimpleType.getBuiltInDatatypes();
    XSDSimpleType baseType = (XSDSimpleType)h.get("string");
    type = XSDSimpleType.derivedFrom(baseType,"string", " ");
    XSDSimpleType stype = (XSDSimpleType)type;
    stype.setFacet("maxLength","10");
    stype.setFacet("minLength","1");
    stype.setFacet("enumeration","en");
    stype.setFacet("enumeration","es");
    String nodeValue = elemValue.getLexicalValue();
    stype.validateValue(nodeValue);
    super.setNodeValue(nodeValue);
    catch (Exception e)
    throw new InvalidContentException("Error: Invalid value.");
    public Lang(String value)
    throws InvalidContentException
    try
    Hashtable h = XSDSimpleType.getBuiltInDatatypes();
    XSDSimpleType baseType = (XSDSimpleType)h.get("string");
    type = XSDSimpleType.derivedFrom(baseType,"string", " ");
    XSDSimpleType stype = (XSDSimpleType)type;
    stype.setFacet("maxLength","10");
    stype.setFacet("minLength","1");
    stype.setFacet("enumeration","en");
    stype.setFacet("enumeration","es");
    stype.validateValue(value);
    super.setNodeValue(value);
    catch (Exception e)
    throw new InvalidContentException("Error: Invalid value.");
    public void addTable(TestType.Lang.Table thetable)
    throws InvalidContentException
    super.addElement(thetable);
    public static class Table extends CGXSDElement
    static final String name = "table";
    static final String namespace = "http://xmlns/test";
    public Table()
    super();
    public void setType(TestType.Lang.Table.Table_Type elemtype)
    throws IllegalArgumentException
    this.type = elemtype;
    public void print(XMLOutputStream out)
    throws IOException
    super.printAttributes(out, name, namespace);
    public static class Table_Type extends CGXSDElement
    static final String name = "Table_Type";
    static final String namespace = "http://xmlns/test";
    protected Integer aborder;
    protected Integer acellspacing;
    protected Integer acellpadding;
    public void setBorder(Integer theborder)
    throws IllegalArgumentException
    this.aborder = theborder;
    super.addAttribute("border" , theborder);
    public Integer getBorder()
    throws IllegalArgumentException
    return this.aborder;
    public void setCellspacing(Integer thecellspacing)
    throws IllegalArgumentException
    this.acellspacing = thecellspacing;
    super.addAttribute("cellspacing" , thecellspacing);
    public Integer getCellspacing()
    throws IllegalArgumentException
    return this.acellspacing;
    public void setCellpadding(Integer thecellpadding)
    throws IllegalArgumentException
    this.acellpadding = thecellpadding;
    super.addAttribute("cellpadding" , thecellpadding);
    public Integer getCellpadding()
    throws IllegalArgumentException
    return this.acellpadding;
    public void addTr(TestType.Lang.Table.Table_Type.Tr thetr)
    throws InvalidContentException
    super.addElement(thetr);
    public static class Tr extends CGXSDElement
    static final String name = "tr";
    static final String namespace = "http://xmlns/test";
    public Tr()
    super();
    public void setType(TestType.Lang.Table.Table_Type.Tr.Tr_Type elemtype)
    throws IllegalArgumentException
    this.type = elemtype;
    public void print(XMLOutputStream out)
    throws IOException
    super.printAttributes(out, name, namespace);
    public static class Tr_Type extends CGXSDElement
    static final String name = "Tr_Type";
    static final String namespace = "http://xmlns/test";
    public void addTd(TestType.Lang.Table.Table_Type.Tr.Tr_Type.Td thetd)
    throws InvalidContentException
    super.addElement(thetd);
    public static class Td extends CGXSDElement
    static final String name = "td";
    static final String namespace = "http://xmlns/test";
    public Td()
    super();
    public void setType(TestType.Lang.Table.Table_Type.Tr.Tr_Type.Td.Td_Type elemtype)
    throws IllegalArgumentException
    this.type = elemtype;
    public void print(XMLOutputStream out)
    throws IOException
    super.printAttributes(out, name, namespace);
    public static class Td_Type extends CGXSDElement
    static final String name = "Td_Type";
    static final String namespace = "http://xmlns/test";
    public void addText(String text)
    super.addElement(new String(text));
    public void addCDATA(String text)
    super.addElement(new String(text));
    public Vector getChildElements()
    return super.getChildElements();
    public void print(XMLOutputStream out)
    throws IOException
    super.print(out);
    public void validate(XMLSchema schema)
    public Vector getChildElements()
    return super.getChildElements();
    public void print(XMLOutputStream out)
    throws IOException
    super.print(out);
    public void validate(XMLSchema schema)
    public Vector getChildElements()
    return super.getChildElements();
    public void print(XMLOutputStream out)
    throws IOException
    super.print(out);
    public void validate(XMLSchema schema)
    public Vector getChildElements()
    return super.getChildElements();
    public void print(XMLOutputStream out)
    throws IOException
    super.print(out);

    Malaya_Kishore wrote:
    Inorder to get the advantages of latest features of Java1.6 [*performance, security*, etc], the code needs to be recompiled using JDK1.6Why do you think that?
    As I understand it you have two types of "latest features". Bug fixes, JVM updates and the like in which case recompiling will have no affect. API or language updates, when you will not simply recompile but update your code base to make use off.
    The only thing I can think of that a simple recompile would help with is if the compiler updates. I'd guess this would be minimal .
    Edited by: mlk on 22-Aug-2008 09:40

  • How to get the Weblogic Server Id from within java code

    I would like to log which server (among a cluster) a certain job is running on. Is there a way to get the server id from within Java code (this code is in a session bean if that is relevant.)
    By server id I mean the "Name" column in the summary of servers on the weblogic console.
    Thanks,
    ken

    Use the two entries close to the bottom of the page: "list WebLogic
    MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean.jsp"
    Nils
    Anatoly wrote:
    >
    Cameron,
    That page has these items on it:
    which one do you think helps with my issue?
    Misc WebLogic examples
    LongRunningTask
    Execute tasks in parallel using WebLogic Execute Threads
    Weblogic stats (5.1)
    Reload Servlet(s) programmatically (5.1)
    Network classload from WebLogic:using reflection,or the launcher
    Weblogic 5.1 debugging properties
    Seppuku pattern readme
    Using dynamic proxies to intercept EJB invocations (6.1)
    list WebLogic MBeans:listMBeans.jsp
    display MBean attributes and operations:showMBean
    Thanks to Marcelo Caldas for filter by type option and nice UI!
    Using com.sun.jdmk.comm.HtmlAdaptorServer with WebLogic 6.1
    Cool
    EJBGen
    Dimitri
    back
    "Cameron Purdy" <[email protected]> wrote in message news:<3c7a745d$[email protected]>...
    JMX ... see http://dima.dhs.org/misc/ for some info on JMX in Weblogic.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Anatoly" <[email protected]> wrote in message
    news:[email protected]..
    Does anyone know who to get the managing server URL's port
    from within the EJB code running on Weblogic 6.1?
    The URL port is not default (not 7001), but when creating
    initial context, I am not specifying the URL in properties.
    Due to that, trying to the the PROVIDER_URL property from
    environment does not return anything.
    Appreciate any responses.
    -Anatoly
    ============================
    [email protected]

Maybe you are looking for