Standalone executables and dependencies in the Java World

I'm a very seasoned C/C++ developer who's just learning Java. I have this gnawing question that's bugging me. It's rather elementary but it requires someone with experience to answer it.
If I'm delivering a standalone executable (C/C++) to a Windows or Linux customer, it is possible to deliver simply a "*.exe" file (windows) or a Linux Executable file (Linux) which can be installed and run immediately with no dependencies not included in a typical installation. (although, on linux, if there is a gui involved, a typical default Linux install may be missing some dependencies for the gui )
But in the Java world, since the JRE is not necessarily included in a Standard Windows or Linux default installation, my customer would always have to install the JRE on their machine before they can run any code that I produce in Java ...correct? And there is no way to execute a jarfile as a standalone; it always must be executed by the JRE ("java -jar <jarfilename.jar> ) ...right? And if I were to code a new GUI application in Java on the Linux platform, it would have to be run via "java -jar <gui_jarfilename.jar> ...correct?

R2me2 wrote:
"Your questions cause me to suggest that you look into Java Web Start;"
No, this is exactly what I'm not asking. I mean really standalone ....as in the executable runs by itself without user having to install anything else* (via CD, web or anywhere). So I suppose the answer to my question is that NO, there's no such thing in the Java World and that whenever a java program is installed, it always has the JRE as a dependency and that the installation of a java executable is not complete until the JRE is installed.Not to sound like a noob but what were you expecting. Java runs on the JRE and that is what makes it portable as the JRE can be installed almost anywhere o.O
This is not the inconvenience that you are making it out to be. No user is gonna beef with you if they came to you asking for a java application to be installed and I most certainly have played the client role, having to download the latest JRE to run my bank applets. No so long as you provide the user with all the info they need like a link to JRE download etc you will be fine.. :)

Similar Messages

  • Difference between the standalone executable and an interpreted commond

    In the last of this aricle the author mentioned two commonds, I am not exactly sure the meaning ,can anyone give a interpretation?
    the article:
    [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4]

    On Windows when you start a command prompt, you are running a program called cmd.exe
    When you type "dir" in command prompt cmd.exe itself does something. This is it "interpreting" your command.
    If, however, you type "myprogram.exe" then cmd.exe looks for another program in a file called "myprogram.exe". If it doesn't it issues an error message. This is it (still) interpreting your command. If it does find it, however, it runs your program. That program is a "standalone executable".
    The distinction becomes relevant when you consider a more complicated command like this:
    myprogram.exe > myfile.txt
    This instructs cmd.exe to run your program but send any of its output to a file. Your program doesn't know how to do that second part. That's up to the interpreter.
    So if you use Java to launch your program it would make no sense to tell it to redirect in this way; you would have to launch cmd.exe and tell that to in turn run your program and do the redirect.

  • Help with calling windows executable and hiding it using java

    Hi,
    I have a small utility which calls sqlplus from java , which basically executes a sql file .
    Process sqlProcess = runtime.exec(command);
    Where command is string and has all the required parameters.
    (sqlplus_exe , username_password_sid , sql-file_to_execute_path)
    This works fine but it pops up a sql plus window on screen which kindof the user has control .
    Like the user can close that sqlplus window before the script gets executed completely.
    I want that window to be hidden so that user doesn't have any control on the window and can't interfere with the sql execution.
    So thoght about windows api , ShellExecute where you can provide a parameter to hide the window.
    Details are in below
    [http://support.microsoft.com/kb/224816]
    Now the options I have considered to call ShellExecute are JNI / JNA / Smooth
    I am using eclipse hellios on winxp
    JNI
    I Got the code from some website which has all the required files from here [http://www.heimetli.ch/shellexec.html]
    But I am not able to run the code .
    It says Exception in thread "main" java.lang.UnsatisfiedLinkError: no HSWShellExec in java.library.path
    which I am not able to resolve .
    Even I had put the dll and .h file in the JAVA Build Path> Library section.
    JNA
    looks very simple .But I don't know which library to load and call which funtion :(
    JSMOOTH
    It always gives jsmooth.Native.isAvailable() as false.
    And I dont know how to make it true
    And also thinks that it works the other way around i.e. Jsmooth loads the JVM .Don't know if it can be called from within jvm
    So there I am stuck .
    Any suggestions guys.
    Any example code would be great.
    Thanks in advance.
    Edited by: Rajinder_Sandhu on Jul 14, 2010 7:58 AM

    I got it working with JNI and the sample code from the website
    The whole matter was get the path correctly setup in eclipse.
    The solution is posted here.
    [http://www.eclipsezone.com/eclipse/forums/t49342.html]

  • Error when I execute an application with the java command in a DOS prompt

    Hi:
    I have a trouble. I edit the most simple program in Java: hello.java
    In DOS prompt, I compile the program. The result is the file hello.class
    c:\> javac hello.java
    However, I try to execute this program with the command java
    c:\> java hello
    and the DOS prompt send me an error like this: Java.exe has a problem and must be closed.
    I press the option "Don't send". After this, the DOS prompt returns empty and it doesnt execute the application:
    c:\>
    By the way, in an IDE editor like Gel, the file hello.java is compiled and executed correctly without problems.
    I edited other simple Java files, I compiled them succesfully and I can't run them in a DOS pormpt. The result is the same dialog box: "Java.exe has a problem and must be closed".
    The question is: Why don't these programs run in a DOS prompt?
    My Operating System is Microsoft Windows XP and the Java compiler version is: 1.6.0_13
    Thanks in advanced.

    Hi again:
    What happens when you type "java -version"?
    Answer:
    java version "1.2"
    Classic VM (build JDK-1.2-V, native threads)
    What is the value of your %PATH%?
    Answer:
    Path=E:\oracle\product\10.2.0\db_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Archivos de programa\Archivos comunes\Adaptec Shared\System;C:\Archivos de programa\Executive Software\DiskeeperLite\;C:\Archivos de programa\QuickTime\QTSystem\;C:\Archivos de programa\Java\jdk1.6.0_13\bin;C:\Archivos de programa\Microsoft SQL Server\80\Tools\Binn\;e:\Microsoft SQL Server\90\Tools\binn\;C:\BITWARE\;C:\Archivos de programa\Archivos comunes\Ahead\Lib\
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    Have you considered running Linux?
    Answer: No, because Linux is more complex.
    Additional information:
    My Operating System is: Microsoft Windows XP Profesional Version 2002, Service Pack 3, running on an Intel Pentium 4, CPU 2.4 Ghz, RAM: 2.23 Gb

  • HT1338 I have a Callaway range finder and need a software update and they provided the following directions and have changed the Java runtime versions several times to get their exe to update.Hello Doug,  Thank you for contacting Callaway uPro Technical S

    Hello Doug,
    Thank you for contacting Callaway uPro Technical Support.
    Please follow the instructions below to sync your upro mx/mx+ with your computer and update to the latest software - 3.1.005.
    1. Ensure the upro sync software is running on your computer (you will see a black icon at the bottom right of your screen by the clock with a Callaway logo in it).
    2. Plug your device into your computer; select Sync then PC.
    3. The sync software should initialize and launch the uxplore website. If you haven't installed the upro sync software you can download it Here:http://www.callawayuxplore.com/downloads/
    4. Download this: http://media.callawaygolf.com/webupdate/callawaygolf/2012/products/accessories/u pro/upro-mx-plus/downloads/3_1_005_launch.jnlp.zip
    5. Double click "3_1_005_launch," then click the green START button
    NOTE: If you get a "Unable to launch application" error please follow the instructions below.
    1a. Navigate to "Control Panel" through the start menu located in the bottom left of your screen.
    2a. Find and uninstall any "Java" applications. After uninstalling please go back to the start menu and right click on "Computer" or "My Computer" and select "Properties". In the right half of the pop up windows it'll say the Operating system your computer is running. If it says x64 bit click: http://tinyurl.com/lhkps2rto download the correct java for your computer. If it doesn't have a number please click: http://tinyurl.com/qysyctb to download the correct Java.
    3a. Once the correct Java is installed please follow steps 1-5 listed above.
    4a. To update your Java back to 7 please click: http://java.com/en/download/index.jsp. Once on the page select "Free Java Download" to run the download (Make sure to uncheck any Mcafee or toolbar installations during the installation).
    Once the update has completed the device will restart itself. At that time you can unplug it or select Sync and PC to launch the uxplore site again to continue syncing courses.
    NOTE: Do not try to sync courses to the unit while the update is running or both processes will fail. 

    Java isn't a part of the Mac OS X anymore, so you will need to install a version of Java. However, I don't know what version of java is required for this software. You need to explain to their support that you are using a Mac and what OS you are running. Download the latest java and see if that works.

  • Specifying Schema Location in XML file and not in the Java code

    I have a repository of schema xsd files. When I receive my xml file, I need to validate it against the specified schema. The xml file would declare the schema location, using the following syntax:
    <CERD:CERD xsi:schemaLocation = "..\CERD.xsd" xmlns:CERD = "CERD.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
    Is it really necessary to define the schema location again in the JAVA code? Why set the schemaLocation in the xml file at all then?
    Does anybody have any examples where the schema location is not set in the JAVA code? I am using Java 1.6, and at this point in time I only need to validate. Any help would be appreciated.

    Thank you very much for your quick reply. I have made some progress but I am still stumped.
    In my code I am doing this:
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = factory.newSchema();
    Validator validator = schema.newValidator();
    validator.validate(XML_SOURCE);
    I find this works if my schema does not have a target namespace. I have downloaded the following simple example from the internet that uses a target namespace and it fails:
    library1.xsd:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://example.org/prod"
    xmlns:prod="http://example.org/prod">
    <xsd:element name="product" type="prod:ProductType"/>
    <xsd:complexType name="ProductType">
    <xsd:sequence>
    <xsd:element name="number" type="xsd:integer"/>
    <xsd:element name="size" type="prod:SizeType"/>
    </xsd:sequence>
    <xsd:attribute name="effDate" type="xsd:date"/>
    </xsd:complexType>
    <xsd:simpleType name="SizeType">
    <xsd:restriction base="xsd:integer">
    <xsd:minInclusive value="2"/>
    <xsd:maxInclusive value="18"/>
    </xsd:restriction>
    </xsd:simpleType>
    </xsd:schema>
    <prod:product xmlns:prod="http://example.org/prod"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="library1.xsd"
    effDate="2001-04-02">
    <number>557</number>
    <size>10</size>
    </prod:product>
    I get the following SAXParseException when I validate:
    [line 4, col 36|
    cvc-elt.1: Cannot find the declaration of element 'prod:product'.
    Am I doing something wrong with the namespace declaration?
    Edited by: alfredamorrissey on Oct 31, 2007 6:34 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Executable and dependencies

    Labview 2012/Windows 7.
    On my developemnt machine I created a project w all my vis to run a test.  That works fine.  I then created an exe and that works fine.  Then I created an installer for the target machine and the code doesn't work.  I get that its missing files and those files just happen to be listed under "dependencies" of the project  on the devmnt machine.  To name a few..."vi.lib", "instr.lib", nidmm_32.dll", niswitch_32.dll".  In the build I included DAQmx and visa as well as the RT engine.  I selected my "Main Menu" as the "startup vi.  Main menu calls all of the "other vis"  which are in folders in the project under main menu.  The discussion grps have some confusing info.  Should I put the "other vis" that my main menu calls in the "Always Include" box or when I select main menu as my startup vi Labview is smart enough to include those called vis??
    What am I missing that I get an error when I port my code to the target machine ?  ..."vi.lib", "instr.lib", nidmm_32.dll", niswitch_32.dll".

    Hi Clint,
    as you miss "nidmm.dll" I guess you need to install the NI-DMM driver as well with your exectable…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • What's going on in the java world?

    Hi guys,
    I haven't used Java since 2002. What's going on here. Would u tell me? Will be a great help.
    Thanx.
    shoovo

    Hi guys,
    I haven't used Java since 2002. What's going on here.
    Would u tell me? Will be a great help. A lot actually. Java has come of age. It's fast, stable and the Swing emulations really passable.
    The abandoned Java3D has made a come back as open source (kind of).
    A new major Java version called Tiger has been released with lots of language changes that elevates the Java abstraction level a notch. This includes generics, autoboxing and highlevel concurrency.
    Eclipse is better than ever.

  • Import Package problems and error in the Java file created in runtime

    got the following error message when i try to load the JSP file given below (FlightSearch.jsp). Given also below the JAVA files (flightsearch$jsp.java) created by the compiler.
    Thanks for your help
    Susan
    Error message
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:320: 'catch' without 'try'.
    } catch (Throwable t) {
    ^
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:328: 'try' without 'catch' or 'finally'.
    ^
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:328: '}' expected.
    ^
    3 errors, 1 warning
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
    at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
    at java.lang.Thread.run(Thread.java:536)
    FlightSearch.jsp
    <%@page import="java.util.*" errorPage="ErrorHandler.jsp"%>
    <%@page import="com.client.entity.Flight"%>
    <%@page import="com.client.wsclient.FlightServiceClient"%>
    <H3>Available Flight List</H3>
    <br>We have found the following Available flight(s) : </br>
    <table border="0" cellpadding="0" cellspacing="0" width="100">
    <tr>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Flight Company</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Flight Number</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Depart From<font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrive</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Departure Date</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Departure Time</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrival Date</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrival Time</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Adult Fare</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Child Fare</font></b></td>
    </tr>
    <%
    //Get the search information
    String des = request.getParameter("DFrom");
    String arr = request.getParameter("DTo");
    String fy = request.getParameter(FYear.value);
    String fm = request.getParameter(FMonth.value);
    String fd = request.getParameter(FDay.value);
    String f1 = fy + "-" + fm;
    String FDat = f1 + "-" + fd;
    String ty = request.getParameter(TYear.value);
    String tm = request.getParameter(TMonth.value);
    String td = request.getParameter(TDay.value);
    String t1 = ty + "-" + tm;
    String TDat = t1 + "-" + td;
    String type;
    if( request.getParameter(type[0].checked))
    type = "Return";
    else
    { type = "OneWay";
    String clas;
    if(request.getParameter(clas[0].checked))
    {clas = "ECO";
    else
    {clas = "BUSS";}
    String adult = request.getParameter(Adult.value);
    String child = request.getParameter(Child.value);
    //Get the server Flight Search Service URL
    // ServerFlightSearchBO SFSBO = new ServerFlightSearchBO();
    // ServerFlightSearch FlightSearch = SFSBO.getFlightSearchURL();
    // FlightSearchServiceClient FSearchServiceClient = new FlightSearchServiceClient
    String ServerFlightServiceURL = "http://localhost:7080/AServer/services/FlightService";
    //Find available Flight
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(des, arr, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    %>
    <tr>
    <td width= "10%"><%=flt.getFlightComp()%></td>
    <td width= "10%"><%=flt.getFlightNum()%></td>
    <td width= "10%"><%=flt.getDestination()%></td>
    <td width= "10%"><%=flt.getArrive()%></td>
    <td width= "10%"><%=flt.getFrDate()%></td>
    <td width= "10%"><%=flt.getFlightDptTm()%></td>
    <td width= "10%"><%=flt.getToDate()%></td>
    <td width= "10%"><%=flt.getFlightArrTm()%></td>
    <%
    int adt, chld;
    int far_A, tot_A, far_C, tot_C;
    adt = Integer.parseInt(adult);
    far_A = flt.getAdultFr();
    tot_A = adt * far_A;
    chld = Integer.parseInt(child);
    far_C = flt.getChildFr();
    tot_C = chld * far_C;
    %>
    <td width= "10%"><%=tot_A%></td>
    <td width= "10%"><%=tot_C%></td>
    </tr>
    <%
    if(type = "Return")
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(arr, des, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    %>
    <tr>
    <td width= "10%"><%=flt.getFlightComp()%></td>
    <td width= "10%"><%=flt.getFlightNum()%></td>
    <td width= "10%"><%=flt.getFlightDpt()%></td>
    <td width= "10%"><%=flt.getFlightArr()%></td>
    <td width= "10%"><%=flt.getFlightDptDt()%></td>
    <td width= "10%"><%=flt.getFlightDptTm()%></td>
    <td width= "10%"><%=flt.getFlightArrDt()%></td>
    <td width= "10%"><%=flt.getFlightArrTm()%></td>
    <%
    int adlt, chd;
    int fare_A, totA, fare_C, totC;
    adlt = Integer.parseInt(adult);
    fare_A = flt.getAdultFr();
    totA = adlt * fare_A;
    chd = Integer.parseInt(child);
    fare_C = flt.getChildFr();
    totC = chd * fare_C;
    %>
    <td width= "10%"><%=totA%></td>
    <td width= "10%"><%=totC%></td>
    </tr>
    <%
    %>
    </table>
    flightsearch$jsp.java
    package org.apache.jsp;
    import java.util.*;
    import com.client.entity.Flight;
    import com.client.wsclient.FlightServiceClient;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import org.apache.jasper.runtime.*;
    public class flightsearch$jsp extends HttpJspBase {
    static {
    public flightsearch$jsp( ) {
    private static boolean jspxinited = false;
    public final void jspxinit() throws org.apache.jasper.runtime.JspException {
    public void _jspService(HttpServletRequest request, HttpServletResponse response)
    throws java.io.IOException, ServletException {
    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    String _value = null;
    try {
    if (_jspx_inited == false) {
    synchronized (this) {
    if (_jspx_inited == false) {
    jspxinit();
    jspxinited = true;
    _jspxFactory = JspFactory.getDefaultFactory();
    response.setContentType("text/html;ISO-8859-1");
    pageContext = _jspxFactory.getPageContext(this, request, response,
    "ErrorHandler.jsp", true, 8192, true);
    application = pageContext.getServletContext();
    config = pageContext.getServletConfig();
    session = pageContext.getSession();
    out = pageContext.getOut();
    // HTML // begin [file="/client/flightsearch.jsp";from=(0,59);to=(1,0)]
    out.write("\r\n");
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(1,43);to=(2,0)]
    out.write("\r\n");
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(2,58);to=(19,0)]
    out.write("\r\n\r\n<H3>Available Flight List</H3>\r\n<br>We have found the following Available flight(s) : </br>\r\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\">\r\n <tr>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Flight Company</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Flight Number</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Depart From<font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrive</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Departure Date</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Departure Time</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrival Date</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrival Time</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Adult Fare</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Child Fare</font></b></td>\r\n </tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(19,2);to=(66,0)]
    //Get the search information
    String des = request.getParameter("DFrom");
    String arr = request.getParameter("DTo");
    String fy = request.getParameter(FYear.value);
    String fm = request.getParameter(FMonth.value);
    String fd = request.getParameter(FDay.value);
    String f1 = fy + "-" + fm;
    String FDat = f1 + "-" + fd;
    String ty = request.getParameter(TYear.value);
    String tm = request.getParameter(TMonth.value);
    String td = request.getParameter(TDay.value);
    String t1 = ty + "-" + tm;
    String TDat = t1 + "-" + td;
    String type;
    if( request.getParameter(type[0].checked))
    type = "Return";
    else
    { type = "OneWay";
    String clas;
    if(request.getParameter(clas[0].checked))
    {clas = "ECO";
    else
    {clas = "BUSS";}
    String adult = request.getParameter(Adult.value);
    String child = request.getParameter(Child.value);
    //Get the server Flight Search Service URL
    // ServerFlightSearchBO SFSBO = new ServerFlightSearchBO();
    // ServerFlightSearch FlightSearch = SFSBO.getFlightSearchURL();
    // FlightSearchServiceClient FSearchServiceClient = new FlightSearchServiceClient
    String ServerFlightServiceURL = "http://localhost:7080/AServer/services/FlightService";
    //Find available Flight
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(des, arr, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(66,2);to=(68,18)]
    out.write("\r\n<tr>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(68,21);to=(68,40)]
    out.print(flt.getFlightComp());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(68,42);to=(69,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(69,21);to=(69,39)]
    out.print(flt.getFlightNum());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(69,41);to=(70,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(70,21);to=(70,41)]
    out.print(flt.getDestination());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(70,43);to=(71,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(71,21);to=(71,36)]
    out.print(flt.getArrive());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(71,38);to=(72,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(72,21);to=(72,36)]
    out.print(flt.getFrDate());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(72,38);to=(73,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(73,21);to=(73,41)]
    out.print(flt.getFlightDptTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(73,43);to=(74,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(74,21);to=(74,36)]
    out.print(flt.getToDate());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(74,38);to=(75,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(75,21);to=(75,41)]
    out.print(flt.getFlightArrTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(75,43);to=(76,1)]
    out.write("</td>\r\n ");
    // end
    // begin [file="/client/flightsearch.jsp";from=(76,3);to=(87,1)]
    int adt, chld;
    int far_A, tot_A, far_C, tot_C;
    adt = Integer.parseInt(adult);
    far_A = flt.getAdultFr();
    tot_A = adt * far_A;
    chld = Integer.parseInt(child);
    far_C = flt.getChildFr();
    tot_C = chld * far_C;
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(87,3);to=(88,18)]
    out.write("\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(88,21);to=(88,26)]
    out.print(tot_A);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(88,28);to=(89,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(89,21);to=(89,26)]
    out.print(tot_C);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(89,28);to=(91,0)]
    out.write("</td>\r\n</tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(91,2);to=(100,0)]
    if(type = "Return")
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(arr, des, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(100,2);to=(102,18)]
    out.write("\r\n<tr>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(102,21);to=(102,40)]
    out.print(flt.getFlightComp());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(102,42);to=(103,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(103,21);to=(103,39)]
    out.print(flt.getFlightNum());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(103,41);to=(104,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(104,21);to=(104,39)]
    out.print(flt.getFlightDpt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(104,41);to=(105,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(105,21);to=(105,39)]
    out.print(flt.getFlightArr());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(105,41);to=(106,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(106,21);to=(106,41)]
    out.print(flt.getFlightDptDt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(106,43);to=(107,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(107,21);to=(107,41)]
    out.print(flt.getFlightDptTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(107,43);to=(108,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(108,21);to=(108,41)]
    out.print(flt.getFlightArrDt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(108,43);to=(109,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(109,21);to=(109,41)]
    out.print(flt.getFlightArrTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(109,43);to=(110,1)]
    out.write("</td>\r\n ");
    // end
    // begin [file="/client/flightsearch.jsp";from=(110,3);to=(120,1)]
    int adlt, chd;
    int fare_A, totA, fare_C, totC;
    adlt = Integer.parseInt(adult);
    fare_A = flt.getAdultFr();
    totA = adlt * fare_A;
    chd = Integer.parseInt(child);
    fare_C = flt.getChildFr();
    totC = chd * fare_C;
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(120,3);to=(121,18)]
    out.write("\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(121,21);to=(121,25)]
    out.print(totA);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(121,27);to=(122,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(122,21);to=(122,25)]
    out.print(totC);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(122,27);to=(124,0)]
    out.write("</td>\r\n</tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(124,2);to=(126,0)]
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(126,2);to=(127,8)]
    out.write("\r\n</table>");
    // end
    } catch (Throwable t) {
    if (out != null && out.getBufferSize() != 0)
    out.clearBuffer();
    if (pageContext != null) pageContext.handlePageException(t);
    } finally {
    if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);

    You are missing a closing parens. You have :
    if(type = "Return")
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(arr, des, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){Which opens two parens but you only have one closing parens
    </tr>
    <%
    %>
    </table>

  • Executing jar command from the java application

    Hi All,
    In my application i want to create a jar file with the existing class @ Runtime and want to download . But i tried to execute the jar command via Process.getRuntime, it throws IOException. Please guide me or give the solution

    PavithraKarthikeyan wrote:
    Please guide me or give the solutionQuestion your need for this. Why do you think you need to create the jar file.
    P.S. The jar command is only available if the user has the JDK installed so if he has only the JRE installed then you have a problem using Runtime.exec(). There are classes (java.util.jar.JarFile et al) that will allow you to jar files using Java code.

  • How to execute unix command from the Java program running on Windows

    Hello,
    I need to
    1. Execute a unix shell script from a Java program running on the Windows.
    2. I also need to capture the output of this shell script in my program.
    Please suggest me how to achieve this.
    Thanks in Advance.

    Hi...
    Something is missing here
    If you want to execute a shell script in windows that not posible unless you find or develop a unix shell script parser for windows.
    But if you are trying the execute a unix shell script on a remote unix computer from your java program running on a windows platform you can do that by logging on to the UNIX terminal which is running on port 23 I think.
    You can test this using telnet tool on windows
    just type on command prompt
    telnet <ip of the unix pc> <port number this case 23>
    you should get the unix terminal. If that works you can do the same through java or you can directly conect to port 23 of that pc using sockets that way your program will be platform independant

  • XI System backup and restore for the JAVA Stack

    Hello experts
    I am few queries regarding backup of XI System.
    1- What is the procedure to backup the XI System on AIX OS?
    2- Should I backup the J2EE Engine also with Jload and Java migration toolkit, when I backup the XI System?
    3- If XI system crashes, what is the procedure to restore XI system from backup?
    4- Do I have to restore the J2EE Engine also from backup with XI with the help of Jload and Java migration toolkit. If so, what is the procedure on AIX OS?
    5- If I take a backup of XI system, after 3 days the server crashes. When I restore the backup, how should I recover the lost messages of 3 days?
    Kindly help me out with these issues. If anybody has any documents, kindly email me at [email protected] Points will be rewarded for any kind of help. Thanks a ton in advance.

    Hi Bipin,
    This blog contains very little info. It says zip the XI files and extract the compressed zip files. Also it talks about backup of registry.
    I am on AIX OS. How can I backup the registry in AIX? Also how should I zip all the files and extract those compressed files during restore. Is there any SAP utility to do that. Kindly let me know.

  • Unable to access /irj and /nwa on the java netweaver 7.01 after update.

    Unable to access the http://localhost:50100/irj and http://localhost:50100/nwa only http://localhost:50100 is working.
    System info is also working.
    Tried to check for different threads but none of them suggest any solution.
    Error while accessing irj portal through http://<HOST Name- FULL FQDN>:<PORT>/irj:
         Portal runtime error.
    An exception occurred while processing your request. Send the exception ID to your portal administrator.
    Exception ID: 07:49_14/06/11_0003_15728450
    Refer to the log file for details about this exception.
    Error while accessing nwa portal through http://<HOST Name- FULL FQDN>:<PORT>/nwa:
      500   Internal Server Error
      SAP J2EE Engine/7.01 
      Application error occurred during request processing.
      Details:   java.lang.NoSuchMethodError: com.sap.security.core.util.imp.LogonUtils.getOriginalURLFromCookie(Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
    Exception id: [000C2983A61700730000003B00001E940004A5AC7B50D8FB]
    The sapjeecore is at the sp9
    have already applied EHP1 netweaver  stack
    thanks
    Harshit

    Hi Harshit,
    You mention "Unable to access the http://localhost:50100/irj and http://localhost:50100/nwa only http://localhost:50100 is working."
    But did you tried  http://<HOST Name- FULL FQDN>:50100 ?
    Check whether this is working alright if not then it is related to either firewall or some network config issue (e.g. DNS or IP resolution issue).
    Regards,
    Pinkle

  • How to execute *.BAT file from  the Java Application

    Hello to all.
    I wants to run *.BAT file form my applicaion.
    Can u give the code of that two-four line,please
    Wating four your replay.
    Yours Friend
    Bhavin Shah.....

    pr = rt.exec("cmd.exe /c start " + yourProgramName)The exec() method executes the command you specify in the argument and returns a process. In this example, it's telling Windows to run "yourProgramName".
    HTH

  • Solve the problem that stumped the Java world

    A little background: For a couple of weeks I have been posting queries for help
    with several problems in my table-based application. Usually I have gotten calls
    for more code. I have stripped the app down to the ONE problem that remains. The
    code included below is 772 lines long (down from over 2500) for five files.
    I post this query for anyone who is still interested in the problem.
    I am hoping that the solution is short work for an experienced Java coder, though I can't figure it out.
    Table1               145
    Table2               152
    T1RowDragger     211
    T2RowDragger     243
    "main" class     21
         total          772
    The goal is to copy a row from one JTable (table1) to another (secondTable). To do
    that I need to connect "t1DataModel," the DefaultTableModel of table1 to
    "T2RowDragger," the Drag and Drop class of secondTable.
    This is the method which should handle the copy It is located in "T2RowDragger":      public void interTableCopy( int rowNumber, int position ) {
              DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();      -------- the problem
              Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
              t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         }However, it returns a NullPointerException at the first line of the method.
    My diagnostic printout to the console reads:
         "t1DataModel = null
         t2DataModel = SecondTable$SecondTableModel@202ac00
         t2SourceRowData = [, , , , , , , ]
         T2RowDragger: Drag Dropped at : Row 12"
    When this version is run:
         public void interTableCopy( int rowNumber, int position ) {
         //     DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();
                   System.out.println( "t1DataModel = " + t1DataModel );
         //     Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
         //          System.out.println( "t1SourceRowData = " + t1SourceRowData );
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
                   System.out.println( "t2DataModel = " + t2DataModel );
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
                   System.out.println( "t2SourceRowData = " + t2SourceRowData );
         //     t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         }Please note that (1) the drag and drop code is written in the Macintosh API. (2) the code is not exactly pretty.
    As always many thanks for any assistance.
    ---------------------------- code Starts here -------------------------------
         Table1.java ------------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.text.*;
    import java.awt.Toolkit;
    class Table1 extends JTable {
         JFrame frame;
         JTable table1;
         JTable secondTable;
         SecondTable table2;
         TableColumnModel t1ColumnModel;
         TableColumnModel t2ColumnModel;
         JPanel topPanel;
         JPanel buttonPanel;
         public static Color rowDark = new Color( 135, 164, 173 );
         public static Color blueGray = new Color( 164, 176, 172 );
         public static Color greenishLight = new Color( 138, 197, 153 );
         public static Color selected = new Color( 255, 196, 140 ); // yellowishLight
         public static Font test_10ptCraw = new Font("CrawModern", Font.PLAIN, 10);
         private int rows = 40, cols = 8;
         private Object[] rowData = new Object[cols];
         Vector t1DataVector;
         Vector t2DataVector;
         DefaultTableModel t1DataModel;
         final SecondTable twotable = new SecondTable(t1DataModel);
    // -------------------------------------------------------------------- variables for Drag&Drop
         public static Object sourceTable = "";
         public static Object dropTable = "";
         public static int startRow;
         public static int dropRow;
    class T1Model extends DefaultTableModel {
         public boolean isCellEditable(int row, int col) {
         return true;
    T1Model t1Model = new T1Model();
         public Table1() {
         for( int c = 0; c < cols; c++ ) {
              t1Model.addColumn( "Column " + Integer.toString(c) );
         for( int r = 0; r < rows; r++ ) {
              for( int c = 0; c < cols; c++) {
              //     rowData[c] = "ONE( " + r + "," + c + ")";
                   rowData[c] = "";
              t1Model.addRow( rowData );
    // -------------------------------------------------------------------------- set up the components
         topPanel = new JPanel();
              topPanel.setPreferredSize( new Dimension( 618, 40 ) );
              //topPanel.setBackground( Color.white );
         buttonPanel = new JPanel();
              buttonPanel.setPreferredSize( new Dimension( 618, 40 ) );
              //buttonPanel.setBackground( Color.white );
    t1DataVector = t1Model.getDataVector();
         table1 = new JTable();
              table1.setModel( t1Model );
              table1.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
              table1.getTableHeader().setReorderingAllowed( false );
              table1.getTableHeader().setResizingAllowed(false);
              table1.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
              table1.setCellSelectionEnabled( false );
              table1.setRowHeight( 20 );
              table1.setGridColor( Color.black );
              table1.addMouseListener( new T1RowDragger( table1, table2, t1DataVector ) ); // ----- addMouseListener
    t1DataModel = (DefaultTableModel)table1.getModel();
    // --------------------------------------------------------------------------- set the TableCellRenderer
    //     TableCellRenderer t1XRenderer = new T1RowAlternatorX();
    //     table1.setDefaultRenderer(Object.class, t1XRenderer);
         JTableHeader t1Header = table1.getTableHeader(); // ------------------------------- TableHeader
         Dimension dim = t1Header.getPreferredSize();
         dim.height = 20;
         t1Header.setPreferredSize(dim);
         t1Header.setFont( test_10ptCraw );
    // -------------------------------------------------------------------- assemble the frame
         frame = new JFrame( "Table1" );
         JScrollPane scrollPane = new JScrollPane( table1 );
         table1.setPreferredScrollableViewportSize(new Dimension(600, 350));
         JPanel mainPanel = new JPanel();
         mainPanel.setLayout(new BorderLayout());
         mainPanel.add(topPanel, BorderLayout.NORTH);
         mainPanel.add(scrollPane, BorderLayout.CENTER);
         mainPanel.add(buttonPanel, BorderLayout.SOUTH);
         frame.getContentPane().add( mainPanel );
         frame.setSize(618, 430);
         frame.setVisible(true);
         } // ------------------------------------------- close out the constructor "public Table1()"
    } // ---------------------------------------------------  close out "class Table1 extends JTable"
    SecondTable.java ------------------------------------------------------------------------------------
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.util.*;
    class SecondTable extends JTable {
         private int rows = 100, cols = 8;
         private Object[] rowData = new Object[cols];
         JFrame frame;
         JTable table1;
         JTable secondTable;
         TableColumnModel t1ColumnModel;
         TableColumnModel t2ColumnModel;
         JPanel topPanel;
         JPanel buttonPanel;
         public static Color rowDark = new Color( 135, 164, 173 );
         public static Color blueGray = new Color( 164, 176, 172 );
         public static Color greenishLight = new Color( 138, 197, 153 );
         public static Color selected = new Color( 255, 196, 140 ); // yellowishLight
         public static Font test_10ptCraw = new Font("CrawModern", Font.PLAIN, 10);
    // -------------------------------------------------------------------- variables for Drag&Drop
         Vector t1DataVector;
         Vector t2DataVector;
         public static Object sourceTable = "";
         public static Object dropTable = "";
         public static int startRow; // change to: sourceRow;
         public static int dropRow;
         class SecondTableModel extends DefaultTableModel {
               public boolean isCellEditable(int row, int col) {
                       return col > 0 && col < 5;
         SecondTableModel t2Model = new SecondTableModel();
    // to pass Table1's data model in the SecondTable ctor.
         DefaultTableModel t1DataModel;
         public SecondTable( DefaultTableModel t1DataModel ) { // ------------------------------------------- the constructor "public SecondTable()"
         this.t1DataModel = t1DataModel;
    //     t2Model = (DefaultTableModel) getModel();
         for( int c = 0; c < cols; c++ ) {
              t2Model.addColumn( "Column " + Integer.toString(c) );
         for( int r = 0; r < rows; r++ ) {
              for( int c = 0; c < cols; c++) {
              //     rowData[c] = "t2 ( " + r + "," + c + ")";
                   rowData[c] = "";
              t2Model.addRow( rowData );
    // ------------------------------------------------------------------------ set up the components
         topPanel = new JPanel();
              topPanel.setPreferredSize( new Dimension( 618, 40 ) );
              topPanel.setBackground( Color.white );
         buttonPanel = new JPanel();
              buttonPanel.setPreferredSize( new Dimension( 618, 40 ) );
              buttonPanel.setBackground( Color.white );
    t2DataVector = t2Model.getDataVector();
         secondTable = new JTable(); // -------------------------------------------------------------- JTable
              secondTable.setModel( t2Model );
         //     secondTable.setColumnModel( t2ColumnModel );
              secondTable.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
              secondTable.getTableHeader().setReorderingAllowed( false );
              secondTable.getTableHeader().setResizingAllowed(false);
              secondTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
              secondTable.setCellSelectionEnabled( false );
              secondTable.setRowHeight( 20 );
              secondTable.setGridColor( Color.black );
              secondTable.addMouseListener( new T2RowDragger( table1, secondTable, t1DataVector,
                                                                          t2DataVector, t1DataModel ) ); // - Drag&Drop addMouseListener
    // -------------------------------------------------------------------- set the TableCellRenderer
    //     TableCellRenderer t2XRenderer = new T2RowAlternatorX();
    //     secondTable.setDefaultRenderer(Object.class, t2XRenderer);
         JTableHeader t2Header = secondTable.getTableHeader(); // ------------------------------- TableHeader
         Dimension dim = t2Header.getPreferredSize();
         dim.height = 20;
         t2Header.setPreferredSize(dim);
         t2Header.setFont( test_10ptCraw );
    // -------------------------------------------------------------------- assemble the frame
         JScrollPane scrollPane = new JScrollPane( secondTable );
         secondTable.setPreferredScrollableViewportSize(new Dimension(600, 350));
         JPanel mainPanel = new JPanel();
              mainPanel.setLayout(new BorderLayout());
              mainPanel.add(topPanel, BorderLayout.NORTH);
              mainPanel.add(scrollPane, BorderLayout.CENTER);
              mainPanel.add(buttonPanel, BorderLayout.SOUTH);
         frame = new JFrame( "SecondTable" );
              frame.getContentPane().add( mainPanel );
              frame.setSize(618, 430);
              frame.setLocation( 200, 200 );
              frame.setVisible(true);
         } // ------------------------------------------- close out the constructor "public SecondTable()"
    } // ---------------------------------------------------  close out "class SecondTable extends JTable"
         T1RowDragger.java ------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    //import com.apple.mrj.dnd.Drag;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class T1RowDragger extends DragAdapter implements DragInitiatorListener {
    static JTable table1;
    static JTable secondTable;
    static Vector t1DataVector;
    //public T1RowDragger( JTable table1, Vector t1DataVector ) {
    public T1RowDragger( JTable table1, JTable secondTable, Vector t1DataVector ) {
    this.table1 = table1;
    this.secondTable = secondTable;
    this.t1DataVector = t1DataVector;
    Object sourceTable = "";
    Object dropTable = "";
         int startRow;
         int dropRow;
         int dragStartRow;
         boolean dragging = false;
         public boolean dragMoved( DragEvent e ) {
         dragEntered( e );
              return true;
         protected void displayDragUnderEffects(Point p) {
              int row = table1.rowAtPoint(p);
              int column = table1.columnAtPoint(p);
              table1.setRowSelectionInterval(row, row);
              table1.setColumnSelectionInterval(column, column);
              //table1.repaint();
         public boolean dragEntered( DragEvent e ) { // ................................. dragEntered
         int dragEnteredRow = table1.rowAtPoint( e.getPoint() );
    //     table1.rowAtPoint( e.getPoint() ).setBackground( selected );
    //     dragEnteredRow.setForeground( selected );
         displayDragUnderEffects( e.getPoint() );
              if ( dragEnteredRow == -1 ) {;
                   System.out.println( "[if] dragEnteredRow = " + dragEnteredRow );
              } else {               
         dragging = true;
                   System.out.println( "Drag Entered at : Row " + dragEnteredRow );
                   System.out.println( "" );
                   return true;
         public boolean dragDropped( DragEvent e ) { // ................................. dragDropped
         dragging = false;
    e.getDrag().setDropAccepted( true );
         if( e.getSource() == table1 ) { // -------------- set "dropTable" variable (in "dragDropped")
              Table1.dropTable = "table1";
         else if( e.getSource() == secondTable ) {
              dropTable = "secondTable";
         int theRow = table1.getSelectedRow();
         int nCol = table1.getSelectedColumn();
         int dragDropRow = table1.rowAtPoint( e.getPoint() );
         dropRow = table1.rowAtPoint( e.getPoint() );
         if ( dragDropRow == -1|| nCol == -1 ) {;
              System.out.println( "[if] dragDropRow = " + dragDropRow );
                                                           // do nothing     
         } else {               
              moveRow( startRow, startRow, dropRow ); // ============================== Call the "moveRow" method
              table1.repaint();
              System.out.println( "startRow : " + startRow );
              System.out.println( "dragStartRow : " + dragStartRow );
              System.out.println( "dropRow : " + dropRow );
         System.out.println( "T1RowDragger: e = " + e );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         System.out.println( "dropTable = " + Table1.dropTable );
              System.out.println( "Drag Dropped at : Row " + dragDropRow );
              System.out.println( "" );
              return false;
         private boolean canAcceptDrag( DragEvent e ) {
              return true; // e.getDrag().allItemsContainFlavors(kAcceptableFlavors);
         // OUTGOING DRAGS:
         public void dragGesture( DragInitiatorEvent e ) { // ............................ dragGesture
              Table1.sourceTable = "table1"; // ---------------------- set "Table1.sourceTable" variable
         startRow = table1.getSelectedRow();
         dragStartRow = table1.getSelectedRow();
              Table1.startRow = table1.getSelectedRow(); // ---------- set "Table1.sourceTable" variable
         if( e.getSource() == table1 ) { // ------------ set "sourceTable" variable (in "dragGesture")
              sourceTable = "table1";
    /*     else if( e.getSource() == secondTable ) {
              sourceTable = "secondTable";
         int nCol = table1.getSelectedColumn();
         OutgoingDrag drag = e.getDrag();
              if ( dragStartRow == -1 || nCol == -1 ) {return; // do nothing
              } else {               
                   Transfer item = new Transfer();
                   //item.addFlavor(OSTypeFlavor.kTypeTEXT, ((String)fContent).getBytes());
                   drag.addItem(item);
                   e.setDragRect( 0, e.getY()+50, 600,20 );// ............... sets drag rectangle graphic
                   System.out.println( "Drag Initiated at: Row " + dragStartRow );
                   System.out.println( "X: " + e.getX() );
                   System.out.println( "Y: " + e.getY() );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         private Object fContent = kTextData;
         private static final String kTextData = "What a drag!";
         public void dragCompleted( DragInitiatorEvent e ) { // .......................... dragCompleted
         public void dragFailed( DragInitiatorEvent e ) { // ............................. dragFailed
         public void moveRow(int startIndex,int endIndex,int toIndex)
            throws IndexOutOfBoundsException {
            int rows = t1DataVector.size();
            if (startIndex >= rows || endIndex >= rows || toIndex >= rows) {
                throw new IndexOutOfBoundsException();
            // Swap if start > end
            if (startIndex > endIndex) {
                startIndex ^= (endIndex ^= (startIndex ^= endIndex));
            // save block to move
            Object[] block = new Object[(endIndex - startIndex) + 1];
            for (int j=0; j < block.length; j++) {
                block[j] = t1DataVector.elementAt(startIndex + j);
              // Copy the stuff to replace the block
              if (startIndex < toIndex) {
                 for (int j=startIndex; j < toIndex; j++) {
                    t1DataVector.setElementAt(t1DataVector.elementAt(block.length + j), j);
              } else if (startIndex > toIndex) {
                 // changed code
                 for (int j=startIndex ; j > toIndex; j--) {
                    t1DataVector.setElementAt(t1DataVector.elementAt(j-1), j);
            // Copy block to new position
            for (int j=0; j < block.length; j++) {
                t1DataVector.setElementAt(block[j], toIndex + j);
         T2RowDragger.java ------------------------------------------------------------------------------
    import java.awt.datatransfer.Transferable;
    import java.awt.datatransfer.DataFlavor;
    import com.apple.mrj.MRJOSType;
    import com.apple.mrj.dnd.*;
    import com.apple.mrj.datatransfer.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    class T2RowDragger extends DragAdapter implements DragInitiatorListener {
         JTable table1;
         JTable secondTable;
         Vector t1DataVector;
         Vector t2DataVector;
    DefaultTableModel t1DataModel;
         public T2RowDragger( JTable table1, JTable secondTable, Vector t1DataVector,
                                       Vector t2DataVector, DefaultTableModel t1DataModel ) {
         this.table1 = table1;
         this.secondTable = secondTable;
         this.t1DataVector = t1DataVector;
         this.t2DataVector = t2DataVector;
         this.t1DataModel = t1DataModel;
         int startRow;
         int dropRow;
    Object sourceTable = "";
    Object dropTable = "";
         // OUTGOING DRAGS:
         public void dragGesture( DragInitiatorEvent e ) { // ............................ dragGesture
              Table1.sourceTable = "secondTable";
         startRow = secondTable.getSelectedRow();
         int dragStartRow = secondTable.getSelectedRow();
         int nCol = secondTable.getSelectedColumn();
         OutgoingDrag drag = e.getDrag();
              if ( dragStartRow == -1 || nCol == -1 ) {return; // do nothing
              } else {               
                   Transfer item = new Transfer();
                   item.addFlavor(OSTypeFlavor.kTypeTEXT, ((String)fContent).getBytes());
                   drag.addItem(item);
                   e.setDragRect( 0, e.getY()+50, 618,20 );
                   System.out.println( "T2RowDragger: Drag Initiated at: Row " + dragStartRow );
                   System.out.println( "X: " + e.getX() );
                   System.out.println( "Y: " + e.getY() );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         public boolean dragMoved( DragEvent e ) {
         dragEntered( e );
              return true;
         protected void displayDragUnderEffects(Point p) {
              int row = secondTable.rowAtPoint(p);
              int column = secondTable.columnAtPoint(p);
              secondTable.setRowSelectionInterval(row, row);
              secondTable.setColumnSelectionInterval(column, column);
              //secondTable.repaint();
         public boolean dragEntered( DragEvent e ) {
         int dragEnteredRow = secondTable.rowAtPoint( e.getPoint() );
         displayDragUnderEffects( e.getPoint() );
              if ( dragEnteredRow == -1 ) {;
                   System.out.println( "T2RowDragger: Entered out of bounds !!" );
              } else {               
                   System.out.println( "T2RowDragger: Drag Entered at : Row " + dragEnteredRow );
                   System.out.println( "T2RowDragger: startRow : Row " + startRow );
                   System.out.println( "T2RowDragger: dropRow : Row " + dropRow );
                   System.out.println( "" );
                   return true;
         public boolean dragDropped( DragEvent e ) { // ................................... dragDropped
              e.getDrag().setDropAccepted( true );
              Table1.dropTable = "secondTable"; // -------------- set "dropTable" variable (in "dragDropped")
              Table1.dropRow = secondTable.rowAtPoint( e.getPoint() ); // -------------- set "dropTable" variable (in "dragDropped")
              int theRow = secondTable.getSelectedRow();  // ------------ superfluous
              int nCol = secondTable.getSelectedColumn();
              Table1.dropRow = secondTable.rowAtPoint( e.getPoint() );
              dropRow = secondTable.rowAtPoint( e.getPoint() );
         if ( Table1.dropRow == -1|| nCol == -1 ) {;
              System.out.println( "T2RowDragger: Dropped out of bounds !!" );
                                                           // do nothing     
         } else {               
    // ---------------------------------------------------------------------- new d&d code, 07/27/01
              if( Table1.sourceTable == "table1" ) {
                   interTableCopy( Table1.startRow, Table1.dropRow );
                   secondTable.repaint();
              else if( Table1.sourceTable == "secondTable" ) {
                   moveRow( startRow, startRow, dropRow );
                   secondTable.repaint();
              System.out.println( "T2RowDragger: Drag Dropped at : Row " + Table1.dropRow );
              System.out.println( "" );
         System.out.println( "sourceTable = " + Table1.sourceTable );
         System.out.println( "dropTable = " + Table1.dropTable );
              System.out.println( "T2RowDragger: startRow : " + startRow );
              System.out.println( "T2RowDragger: dropRow : " + dropRow );
              System.out.println( "Drag Dropped at : Row " + Table1.dropRow );
              System.out.println( "" );
                   return false;
         public void moveRow(int startIndex,int endIndex,int toIndex) throws IndexOutOfBoundsException {
            int rows = t2DataVector.size();
            if (startIndex >= rows || endIndex >= rows || toIndex >= rows) {
                throw new IndexOutOfBoundsException();
            // Swap if start > end
            if (startIndex > endIndex) {
                startIndex ^= (endIndex ^= (startIndex ^= endIndex));
            // save block to move
            Object[] block = new Object[(endIndex - startIndex) + 1];
            for (int j=0; j < block.length; j++) {
                block[j] = t2DataVector.elementAt(startIndex + j);
              // Copy the stuff to replace the block
              if (startIndex < toIndex) {
                 for (int j=startIndex; j < toIndex; j++) {
                    t2DataVector.setElementAt(t2DataVector.elementAt(block.length + j), j);
              } else if (startIndex > toIndex) {
                 // changed code
                 for (int j=startIndex ; j > toIndex; j--) {
                    t2DataVector.setElementAt(t2DataVector.elementAt(j-1), j);
             // Copy block to new position
            for (int j=0; j < block.length; j++) {
                t2DataVector.setElementAt(block[j], toIndex + j);
         public void dragCompleted( DragInitiatorEvent e ) { // .......................... dragCompleted
         public void dragFailed( DragInitiatorEvent e ) { // ............................. dragFailed
         private boolean canAcceptDrag( DragEvent e ) {
              return true; // e.getDrag().allItemsContainFlavors(kAcceptableFlavors);
         private Object fContent = kTextData;
         private static final String kTextData = "T2RowDragger: What a drag!";
         public void interTableCopy( int rowNumber, int position ) {
    //          DefaultTableModel t1DataModel = (DefaultTableModel)table1.getModel();
                   System.out.println( "t1DataModel = " + t1DataModel );
    //          Object t1SourceRowData = t1DataModel.getDataVector().elementAt(rowNumber);
    //               System.out.println( "t1SourceRowData = " + t1SourceRowData );
              DefaultTableModel t2DataModel = (DefaultTableModel)secondTable.getModel();
                   System.out.println( "t2DataModel = " + t2DataModel );
              Object t2SourceRowData = t2DataModel.getDataVector().elementAt(rowNumber);
                   System.out.println( "t2SourceRowData = " + t2SourceRowData );
    //          t2DataModel.getDataVector().setElementAt(t1SourceRowData, position);
              t2DataModel.fireTableRowsUpdated(position, position);
              secondTable.repaint();
         public void selectiveCellCopy() {
              int sR = 1;               
              firstEmptyRow = 11;
              for ( int sC = 1; sC < 4; sC++ ) {                    
                   Object value = table1.defaultTableModelX.getValueAt( sR, sC );
                   DefaultTableModel t2DataModel = (DefaultTableModel)twotable.secondTable.getModel();
                   t2DataModel.setValueAt( value, firstEmptyRow, (sC + 4) );
         //          t2Model.setValueAt( value, firstEmptyRow, (sR + 4) );           
         TableSetGo5.java ------------------------------------------------------------------------------
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableSetGo5 {
         public static void main(String args[]) {
              Table1 tableOne = new Table1();
         //     SecondTable tableTwo = new SecondTable();
         } // ------- closes out "public static void main(String args[])"
    } // ----------- closes out "public class TableSetGo5"---------------------------- code Ends here -------------------------------

    Hi,
    Instantiated a variable is like...
    JTable table1 = new JTable();
    if you do
    JTable table1
    System.out.println(table1);
    JTable table1 = new JTable();
    it will print "null", and if you do,
    table1.someTableMethod() you will get an error!!!!
    Do not take that personnal(;0)))) but I know that you do not have a lot of experiece just by looking at the way you are selecting the name for your variables... like Table1, table1 and secondTable...But believe me, by working here on the forum you will be a pro soon.
    Take care,
    JRG

Maybe you are looking for

  • FI: Open Items and Disputes

    Hi Experts, I would like to know how to retrieve the FI Open items. Basically the SAP tables and criteria to fetch all Open Items. Also, how to identify the disputes in the items. Best Regards, Kurtt

  • Can I monitor multiple iPad screens on a single iPad?

    I'm a teacher and we have distributed iPads to many of our students recently. We have a few issues with ensuring the pupils are using the iPads as we have asked and are not using it to access social media, games and messaging etc during class time. I

  • How to make flash animation using images

    Hello all dear, please give me solution of my problem please look at the headline

  • How to "turn off" dispatch of MQ to mdb through bridge?

    I'm doing some research on architectural options for an application. I'm looking at integrating MQ and JMS (MDB) with the Messaging Bridge. An important requirement will be the ability to have code "turn off" and "turn on" the dispatching of MQ messa

  • Auto-kill Widgets when Aperure fires up

    While widgets can be very useful being only a mouse swish away, they do tend to use machine resources even when not exposed. I use the quitDock widget that kills all widgets thus freeing more resources for Aperture. Is there a way of running quitDock