Seeking problem for how to load object in class Test to class Server...

hello everyone, currently, i put some method named calla() in class Test....i have difficulty when to invoke the method from class Server...this is my Server class code
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.URI;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.Headers;
public class SimpleHttpServer2{
public static void main(String[] args) throws Exception { // for the main method (basic main method)
HttpServer server = HttpServer.create(new InetSocketAddress(12345), 0);
server.createContext("/", new RootHandler());
server.setExecutor(null); // creates a default executor
server.start();
MainDialog a = new MainDialog();
a.calla();
static class RootHandler implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
URI xyz = t.getRequestURI();
String response = "";
String resp = "" + xyz;
if(resp.equals("/?act=1")){
// put in wait_doc code
// then if a document is ready,
// put the results of the read in response below
response = "Waiting to read";
  // ClassLoader newClassLoader = new
   //       java.net.URLClassLoader( newClassLoader.calla );
// response = a.calla();
}else if(resp.equals("/?act=2")){
response = "Initialise the reader";
}else
response = "Error!";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}i hope u guys can pull me out from this problem...thank you

i want to run it in my browser....but the process didnt show up...its just run in my IDE called Netbeans....bcause i can see i put the object at main class...so, it just directly call it...but, what i want to do is, if at browser, i type : http://localhost:12345/?act=1 , it will return to the browser, the process that include in calla() inside Test class....when i put this object below main class, i know, this browser process that calla(), but it just display on my Netbeans not to browser...then, im try use ClassLoaderURI, but still not get....this is my final step in doing my project...if i can invoke this calla() into my browser, then, my project will finish...so, any idea, how to call....previously, im just try put this mehod inside RootHandler method like this:
HttpServer server = HttpServer.create(new InetSocketAddress(12345), 0);
server.createContext("/", new RootHandler());
static class RootHandler implements HttpHandler {
public void handle(HttpExchange t) throws IOException {
URI xyz = t.getRequestURI();
String response = "";
String resp = "" + xyz;
// URI z;
if(resp.equals("/?act=1")){
// put in wait_doc code
// then if a document is ready,
// put the results of the read in response below
response = "Initialise the reader";
MainDialog abc = new MainDialog();
abc.Initialise();
System.out.println("response: " + abc);
  // ClassLoader newClassLoader = new
   //       java.net.URLClassLoader( newClassLoader.calla );
// response = a.calla();
}else if(resp.equals("/?act=2")){
response = "Waiting the reader";
MainDialog abc = new MainDialog();
abc.Reader();
}else
response = "Error!";
t.sendResponseHeaders(200, response.length());
OutputStream os = t.getResponseBody();
os.write(response.getBytes());
os.close();
}but, its just run in my IDE again, not to browser...so, how to settle this problem??

Similar Messages

  • Blend2java how i load object which exported by blender with blend2java

    now i'm interesting in blender which is 3D modeling's software. and blend2java is python's script with can help you export your object( model) to xml or gzip for use in java3d. i read and do about this tutorial
    http://blend2java.sourceforge.net/blend2java-howto.html this tutorial show about solution of getting one file into java3d
    but i create object with multiple materials. then get multiple file after export.
    such as i create object with 3 materials. i receive 3 file after export
    problem is :
    how do i get these files for one object into java3d?

    don't know if you're still interested, but if you request help through the sourceforge page for blend2java I can help.

  • How to load the same classes of the same name, from different jars

    Hi,
    I have several different versions of my project in respective jars. I am trying to develop a configuration app, which will have the most current version of my app packaged within it. Then the user will make a selection, and if that selection is an older version, a specific class from one of the jars...which will continue to load other classes within that same jar. If it is the current version, the class will be found within the codebase.
    My question is if this is even possible? Can I load a class from a jar file which has the same file name and package as what is in my current code?

    nasch_,
    So I have been searchin around, and found some good tutorials on classloaders, But i still see a problem.
    Whether I use the same classloader for different sources or not, the problem lies within the reference to the class i am loading. Since this class (a different version of it), is also in the classpath, how does the code know which class is being returned?
    I am having trouble putting this into words, but basically. i don't see how my application will know that i am returning an instance of a class which is not in my classpath.

  • How to load all the classes in a JAR file at runtime?

    Any clues o:
    "How can I force JVM to load all the classes in a specified JAR at once?"
    Thanx!
    -Rajeev

    Well I was thinking may be there exists an option with "java", when I
    am starting an application from a jar file, I could force it to load all
    the classes in the JAR. I don't want to do it programically. Is there such
    an option available?? Or in other words can I ask JVM to not do the dynamic
    loading for the JAR??
    Thanx.
    List all JarEntries and convert the paths to fully
    qualified class files
    e.g file in jar
    [1] /com/mycompany/proj/X.class
    should become
    [2] com.mycompany.proj.X
    then for each entry issue
    Class.forName( [2] );

  • A problem that how to communicate between PLC S7-300 and IA Server

    The PC running the OPC server is connected to PLC S7-300 via the RS232 serial port and the Siemens RS232-MPI adapter (product no. 6ES7972-0CA23-0XA0).
    But I encounter such problem when I create an object(S7_HMI)in IA Server:
    Step 1:
    links:http://www.simwe.com/forum/upload/2005/04/30/87472755.jpg
    Error message:
    Protocol error:Unexpected response from PLC
    links:http://www.simwe.com/forum/upload/2005/04/30/48471774.jpg
    When I communicate between S7-300 and PC by LOOKOUT 5.1,it works well.
    Could someone give me help? Thanks a lot.帖子被qzxin在05-08-2005 04:54 AM时编辑过了
    帖子被qzxin在05-08-2005 04:56 AM时编辑过了

    First of all, Thank You very much for Your answer.
    I'm using the TS Adapter that make the conversion from MPI to the serial bus.
    I have made yet control panels to supervisor systems with Omron PLCs and I correctly use the DataSocket with the DSC module: with Omron PLCs I've never had any problems of communications. The problems is now with Siemens. For the communication between control panel and PLC I have to use the internal modem of my computer and the OPC is S7_MPI of IA opc Server.I wondering if this OPC is ok for modem communications (inside there is a form to insert the phone number of the remote station) or if every kind of modem are compatible with S7-300 modem it has inside.I've noted that my computer modem don't do the phone number when i run the front panel!In running mode, if I take a look to the Block Diagram and I click the "Highlight Execution" button I don't see any animation on the code generated by the HMI Wizard to connect the only one tag to the DataSocket URL.
    Have You any other suggestions to solve the problem?
    Massimo Lazari

  • How to find objects and classes

    hi
    any notes or path on objects and classes on crm?

    Hi Kumara
    I beleive your talking about the Classification system.
    To get to this go here: SPRO->IMG->Cross-Application Components - -> Classification System - -> Classes - -> Maintain Object Keys
    This will give a list of Tables which are currently set with Object Keys, you may need to add a new table and configure.
    Next
    To get to this go here: SPRO->IMG->Cross-Application Components - -> Classification System - -> Classes - -> Maintain Object Types and Class Types
    Here you assign a Class Type to Link your Table from the previous step, this class new Class Type will be used with a New Class to created in the following steps.
    Goto Transaction CT04 - Create Characteristics
    Here you create effectively attributes of a Class (Fields)
    Goto Transaction CL01 - Create New Class
                              or CL02 - Maintain Class
    Create a new class linked to your Class Type from previous steps
    On the Char.. Tab you can add the new Characteristics created in the previous step to your new Class.
    Based on the Object Key from the first step, these new attributes shoulds all now link together. If the key is of type 'RAW'  (Binary) it may not be possible to link correctly, therefore some ABAP maybe required to create the link, depending on your application.
    Hope this helps.
    <b>Reward with points if useful.</b>
    Regards
    Arden

  • How to load objects in web application context during oc4j startup?

    Hi
    How I can put some objects in application context during oc4j application startup?
    I'm using oracle as10g j2ee and web cache edition.
    Thanks

    An idea would be to write your own OC4JStartup implementing class and have this thing create the objects you want and bind them to JNDI.

  • JDBC Connection Driver Problem for Oracle in a J2EE servlet/class

    Hi,
    I am having a big problem with setting up a JDBC connection with my oracle database, I have been trying to fix it for about 6 hours now with no joy, I have read that many threads about JDBC, class paths etc.. that i dont know which way is up any more!!
    Here is the issue:
    (Please bare in mind that I am new to this when posting replies)
    I have a Web Application set up as a project in the netbeans IDE. I have a servlet which creates a new object call dbaseFunc which is a public class I have wrote and within this class is a function called getAppConfigCon(). The code for this function is below:
    public Connection getAppConfigCon()
    Connection con = null;
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","cavdev", "password");
    catch (SQLException e)
    e.printStackTrace();
    catch (ClassNotFoundException e)
    e.printStackTrace(System.out);
    return con;
    The database is Oracle XE and is installed on the same machine I am developing on, the database is up and I can connect to it via the netbeans IDE database interface after telling it where the driver is (C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip). Obviously this is just IDE functionality and allows you to browse the database objects from netbeans however I now need to know how to tell the jre where the drivers are, right??
    Well like I said multiple forums led me down the classpath route and I have a system environment variable called CLASSPATH set up with the oracle jdbc driver specified as its value, when i run the set command from the command line ( I am running Windows XP Pro) I can see the class path entry in the output as follows:
    CLASSPATH=C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.zip
    When I try to run my web app it doesnt assign the connection object with a value, i.e. when i was debugging my con object was null after calling the method mentioned above. After some time debugging i found a ClassNotFoundException was being thrown when the following command was executed:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Which I understand is because their is a problem with the class path but what is the problem??? The IDE likes the driver so why doesnt the jre.
    I am runnin jdk and jre 1.5, an Oracle XE Database using the netbeans environment.
    Some one please help me, I have spent far to much time on this rather than actually working on my project!!!!
    Thanks
    Keith

    Well After 10.5 hrs I actually sorted this myself, the two problems that were throwing me were this:
    1. Netbeans does not stop the tomcat server when it finishes running the app, you either have to stop the server from the menu or exit netbeans, until the server restarts it will not pick up on any driver files you add to common/lib
    2. You are very right Kiros tomcat does not do .zip files!!!!~~~###
    In order to sort this I had to add the oracle driver as a package to my project using the netbeans ide Project > Libraries > New Jar file, this allowed me to access the oracle classes. Then I had to set the server up to deal with the drivers as well, this meant adding the .jar file (not the latest .zip as it wont work) to the bundled tomcat common lib directory and restart the server via the ide (using the start/stop bat files in the tomcat conf directory doesnt work for some reason when its bundled with netbeans!)
    Thanks for the help guys but in the end it took 10 hrs a lot of reading and 2 bottles of lucozade to keep the brain goin.
    Keith

  • How to load a java class at server start-up

    Hi,
    I have one custome java class that is being referenced by all the applications deployed in OC4J container. How can I load that class automatically and be evailable in the path at server start-up time. Is there an option available to give the class name that also gets loaded automatically.
    Thanks

    To me, you have two mixed issues.
    1. OC4J supports a startup/shutdown model where a named class will be invoked when the container is started (or stopped).
    This is described in the doc here:
    http://download-west.oracle.com/docs/cd/B32110_01/web.1013/b28952/startclas.htm#CIHECEIB
    Note that this specifically calls the methods that are implemented from the respective OC4JShutdown and OC4JStartup interfaces -- the class that is instantiated and called here is not available to all other applications by default. This is more to suit the need where something needs to be done when the container is started/stopped.
    2 The next option is where you just want to make a class available to all applications deployed to the container. For this we provide the shared-library mechanism. Using this you can either make use of the implicit global.libraries shared-lib in which you simply drop JAR files into the j2ee/home/applib directory whereupon the classes will become available by default to all applications. Or you can choose to install a shared-library that contains your specific classes (in a JAR file) and then import that into the default application whereupon the configuration will be inherited by all deployed applications.
    cheers
    -steve-

  • How to load a java class when application is at first time browsed.

    Hi
    How can i load a simple java class on application startup.
    For servlet it could be done using "load on startup" tag in web.xml
    but how could the same be achieved for a simple java class.
    Thanks

    Hi
    Code is given below....
    package com;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Test {
    Test()
         HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
    }Web.xml :
    <servlet>
            <servlet-name>simple</servlet-name>
            <servlet-class>com.Test</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
      <servlet-mapping>
          <servlet-name>simple</servlet-name>
          <url-pattern>/init.do</url-pattern>
        </servlet-mapping>Error Trace :
    org.apache.catalina.core.StandardContext loadOnStartup
    SEVERE: Servlet /DispatcherTest threw load() exception
    java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class com.Test with modifiers ""
         at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
         at java.lang.Class.newInstance0(Class.java:344)
         at java.lang.Class.newInstance(Class.java:303)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:925)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3857)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4118)
         at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1069)
         at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1162)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
         at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1304)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577)
         at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557)
         at java.lang.Thread.run(Thread.java:595)

  • How to load Java properties file dynamically using weblogic server

    Hi,
    We are using Java properties file in Java code. Properties in java properties file are frequently modified. If I keep these properties file in project classpath or as part of war, I will have to redeploy application after each change.
    We are using Weblogic Server.
    Can you please suggest me how can this properties file be loaded at weblogic server startup. Then in that case, how to refer property file in Java code?
    What is the best practice for this?
    Thanks,
    Parshant

    Another alternative is, keep the property file in any pre-defined location. Write a class which reads the properties from the file and returns the one which is requested by caller and deploy this class. Whenever you have to change the properties just update the property file on server and next call to fetch the property should return the updated one.
    Downside of this approach is file I/O everytime. To overcome that you can actually "cache" the properties in a hashmap. Basically when any property if requested, first check the hashmap, if not found then only read from property file and also update in hash map. Next time same property will be returned from hash map itself. The hash map will be cleared at every server restart since its in the memory. You will also need to build a method to clear the hashmap when you update the values in the property file on server.
    This solution would be suitable for small size files and when network overhead of calling a DB needs to be avoided.

  • How to use object of class in Label?

    I have defined a class "time" which runs time for 30 minutes.Now, I want to use this time in Label so that it keep running for 30mins but I am not able to pass the object in Label.

    Of course being aware that this may cause other
    difficulties if you are running a multi-threadedapp.
    SwingUtilities.invokeLater() may be required inthat
    case.I've never really been clear on which of these update
    routines should, or should not be on the dispatcher
    thread. A quick look at the source of JLabel.setText,
    for example, shows that it calls repaint on itself to
    change the presentation of text, and repaint
    shouldn't require to be on the dispatcher thread,
    since it simply adds the paint request to the TODO
    list.That makes sense, but experience doesn't bear it out... I've had deadlocks where the only thing being updated was the text of a label. Perhaps there is something else going on.

  • Java class how to load a JavaFX class?

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

    I want to start a JavaFX application from a Java class,how can implement it?
    Thank you so much!

  • How to load specific driver for specific device not having PnP-ID?

    Hello,
    as mentoined in a previous post I'm up to adapt an exisiting PCMCIA-based PC Card driver so that it can be used with a PCMCIA/USB adaptor (by using it's driver's IOCTLs), and already had
    some success on it: My driver loads and I can read files (for example, in Windows Explorer) from the card as it did before in "PCMCIA version" (I intend to support both with the same driver, which seems
    to work at the moment). As it did before, the driver currently creates a MTD (memory technology device). My main "problem" is how to load the driver.
    The situation is a bit complicated, I try to give as much details as possible.
    For better understanding
    The PCMCIA/USB adaptor's driver usually has following device stack: PCMCIA/SUB adaptors driver -> USB mass storage device (USBSTOR.SYS) -> Diskdrive (DISK.SYS [->PARTMGR.SYS]). For more ease - to see if my driver works in general - I installed my driver
    via INF using the PnP ID of the "USB mass storage device", with other words I "replaced" the USB mass storage driver with my own driver.
    This is my problem
    This means - and that is currently my problem - that may driver gets loaded regardless of what is attached to the PCMCIA/USB adaptor. Usually, when attached to PCMCIA, the PC card has a PnP ID the driver can be assigned to. In my case, I have no PnP ID for
    the PC card, and the driver may stop because the attached device is not supported The driver will unload properly, but the device remains with error code (in device manager).
    What I want to avoid
    I already thought about filter drivers between USBSTOR and the PCMCIA/USB adaptor's driver (#1), or above the USB mass storage device (#2). If I'm correct, that means that I have to handle URB/CBW requests for case #1 or at least SCSI requests for case #2 -
    but I'm currently not familiar with filter drivers, URB/CBW and/or SCSI. Porting the driver was quiete frustating until yet and I had to get familiar with a couple of technologies that belongs to the driver's functinaliy itselfs -
    I hope you understand that I want to avoid getting familiar with more technologies than required.
    I think there must be a way to check the device (PC card) at the PCMCIA/USB adaptor
    before my driver will be loaded, as well as removing the deivce completely if the PC card was removed (so that it disappears in device manager). But I'm currently have no idea how to do that. Is it possible to
    load my driver along the device/driver stack usually created by the PCMCIA/USB adaptor's driver?
    Some answerers likes to refer to WDK documentation and samples. In such case - because of their complexity, it would be nice to get a hint about where to start.
    Have much thanks in before for any suggestions!
    Regards,
    Willi K.

    Today's memory cards (like CFC) manage their FTL (flash translation layer) in their firmware. Our PC card is quiete old technology and does not have such firmware, this is why Windows cannot recognize the file system (FAT). For example, a request to offset
    0 may be somewhere else on our PC Card.
    I followed your suggestion and used the HWID of device that appears "above" the USB mass storage device, and my driver seems to work as it did before - OK, made no difference.
    But if my driver does not recognize the card (because it is not present or it is another PCMCIA device -> STATUS_NOT_SUPPORTED or STATUS_NO_MEDIA in driver entry), and the device is shown with exclamation mark in device manager.
    Two questions remain:
    - How can I ensure that other drivers may attach if my driver does not support the device inserted in the adapter?
    - How can I force a "re-check" of my driver if there was no card present when driver was loaded?? -> Note: A disk drive always appears in device manager - regardless if a device is attached to the apator or not

  • How to load data from different database

    Hi,
    My problem is how to load Foxpro 2.6/clipper data into oracle 8 with all its structure and data with SQL loader or other utility if any.
    And also how can i integrate existing forpro system into Oracle. i.e client will work on Foxpro application and we will only take its output(data files) on daily basis and convert it into Oracle 8.
    Please find any solution.
    Regards
    null

    You can also try to make up an ODBC connection to Foxpro and convert the data from foxpro to oracle using the COPY command (see docs on PL/SQL & OCA). I remember that foxpro/clipper are running on MS-DOS, so I don't know if you can establish an ODBC connection to oracle which can be used from the foxpro/clipper application to use it as a frontend for an oracle database.
    Regards, Kai
    null

Maybe you are looking for

  • Migration from SP12 to SP15

    Hi all, I'm evaluating the migration from SP12 to SP15 on AIX5.3. Has anybody made any negative experiences regarding this issue? Are there any obstacles/glitches I will have to consider? Kind regards, Heiko

  • Error while activating cube contains non cumulative key figures

    Hi all, when i am trying to activate a cube which contains non cumulative key figure it is showing out the following error:      DDIC Object TABL /BIC/LZATTR1NON has not been activated           Table /BIC/LZATTR1NON could not be activated      Pleas

  • HDV edit system setup

    hi i work for a large college in essex, uk, as a video production lecturer and was wndering if someone would help me out with a few questions? we are currently running 18 final cut studio 2 suites on G5's with 4GB of RAM and split hard drives of 170G

  • Using the system variable cpInfoQuizAttempts

    My content is run through an LMS. I am trying to used advanced code using the system variable cpInfoQuizAttempts so that a caption appears when the variable value = 3. Apparently, I can't utilize the value of this variable; in fact, I can't even disp

  • AttachMovie from a loaded SWF

    I'm trying to attach a movie from the library of an SWF I loaded... from what I've read on on the forums, this is possible, however I can't seem to get it to work. My setup for the test files is as follows: CONTAINER.SWF (parent file) - creates empty