Running a java program with eclipse

Hi,
I'm trying to run this java program(below) in eclipse..when i go to the 'run' icon inorder to choose the option 'run as' then 'java application' , i have 'none applicable' as the only option available. is it possibly because the program uses threads?
could someone using eclipse please try to execute this program and let me know if you succeed and how exactly you do it.
package reseaux;
import java.io.*;
import java.net.*;
import java.util.*;
     public class LeServeur extends Thread{
     Socket socket;
     BufferedReader in;
     PrintWriter out;
     Vector FlowList=new Vector(10);
     public LeServeur(Socket socket)throws IOException{
          this.socket=socket;
          in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
          out= new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
     public void run(){
          String s;
          synchronized(FlowList){
               FlowList.addElement(this);
          try{
               while(!(s = in.readLine()).equalsIgnoreCase("/quit")){
                    for(int i=0;i<FlowList.size();i++){
                         synchronized(FlowList){
                              LeServeur monServeur=(LeServeur)FlowList.elementAt(i);
                              monServeur.out.println(s + "\r");
                              monServeur.out.flush();
          catch(IOException e){
               e.printStackTrace();
     finally {
     try {
          in.close();
          out.close();
          socket.close();
     } catch(IOException ioe) {
     } finally {
          synchronized(FlowList) {
          FlowList.removeElement(this);
thanks

thanks...
Infact, i wanted to run the main program called 'Serveur' but it uses 'LeServeur'( the code i sent before') and apparently it gives me an error msg that it doesnot recognise the 'LeServeur'...that's why i was thinking that i should probably first compile the 'LeServeur' so that it can be recognised in the 'Serveur' program.
here is the 'Serveur' code that uses an instantiation of the LeServeur...
package reseaux;
import java.net.*;
import java.io.*;
public class Serveur {
          public int port;
          public ServerSocket skt;
          public Socket socket;
     public static void main(String[] args) {
          int port=8975;
          ServerSocket skt=null;
          Socket socket=null;
          try{
               if(args.length>0)
                    port=Integer.parseInt(args[0]);
          catch(NumberFormatException n){
               System.out.println("This port is used uniquely for listening");
               System.exit(0);
          try{
               skt= new ServerSocket(port);
          while (true){
               socket =skt.accept();
               LeServeur flow=new LeServeur();
               flow.start();
     catch(IOException e){
          e.printStackTrace();
     finally{
          try{
               skt.close();
          catch(IOException e){
               e.printStackTrace();
do you know have any idea why it doesnt recognise the 'LeServeur'?
ps:they're in the same package
thanks

Similar Messages

  • How can i run my java program with out java language

    Hai to every one ..Iam new to java language ...am using windows xp operating system , i did not installed java language in my system .. how can i run a java program with out installing java language... Which files is requied to run java program..?
    any one can help me??

    Hai to every one ..Iam new to java language ...am
    using windows xp operating system , i did not
    installed java language in my system .. how can i run
    a java program with out installing java language...
    you ... can ... not ... do ... this
    Which files is requied to run java program..?
    any one can help me??a JVM. Download it from sun's website.
    [url http://java.sun.com/javase/downloads/index.jsp]Download JavaSE here

  • Running a java program outside eclipse...!

    Hi guys...!
    I wrote a java program that uses different classes. The program deals with xml documents and creates a new xml document. The problem is, the program works fine in eclipse, but when I run through the command line in windows, it complains that it can't see the different classes that I created. Here is one of the error messages:
    Test.java:44:cannont find symbol
    symbol : class Circuit
    location : class src.Test
    Circuit cir = new Circuit ();
    Note: Test.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details
    Does anyone know how to resolve this...?
    Any help from you guys will be very appreciated.
    Thanks..

    I think the problem is probably something like this:
    You have a path thus:
    C:\blahblahblah\With a subdirectory thus:
    C:\blahblahblah\srcIn which you have declared classes thus:
    package src;
    public class Foo {
    }And you have then used a classpath something like the
    following:
    javac -classpath C:\blahblahblah\src Foo.javaThis is incorrect. Your classpath needs to point to
    the root of the package hierarchy. If it's like the
    above, it will look in C:\blahblahblah\src for a
    package src, which results in a path like
    C:\blahblahblah\src\src which does not exist.
    You should set it to:
    C:\blahblahblah\Where that is the root from which your packages
    stem.
    Dave.Thanks Dave. It works man. I really appreciate your help.

  • Why can't I run my Java program with just the JRE, the JDK is required?

    I've recently written 3 programs in Java using the Netbeans IDE with JDK 1.6 as the default Java platform. The compile-time libraries include the Swing Application Framework. I use BuildDesk from ProductiveMe to package the each program into a Windows installer.
    When I install the programs on a new computer without a JRE or JDK being present, and attempt to run them I get an error (as expected) stating that there is no JVM. The messages says that I need to install JDK 1.3 or higher. I downloaded the latest JRE onto the new computer and attempted to run the programs and I get the same error message. My question is, why can't I run these programs with just the JRE installed? Why do I need the JDK? When I install the JDK, the programs run fine. The typical user may not have the JDK on their system, but they likely have the JRE if they've run Java programs before.
    Is the answer as simple as there must be library functions being used by the programs that belong to the JDK, but not the JRE? I'd rather a user not have to install the JDK verses the JRE because they may also have to update some Windows environment variables.
    Thank you for any help on this issue.

    915088 wrote:
    Thanks for your replies. I further investigated BuildDesk and found an option which allows a JVM check but that check needs the JDK. I stopped the JVM check and rebuilt using BuildDesk and it now only requires the JRE to run the programs. The reason why I use BuildDesk is to package more than just the jar file for the user. BuildDesk allows me to create a installation folder structure as well as include any other files in the build. I could just as well zipped all this together for the user but decided against that method.I don't think anyone will question your usage of an installer tool; that is entirely up to you. But what is questionable is that you have problems with that installer tool and then go look for help in a Java programming forum. The next time, go look for help at the source. If there is no way to acquire help (support, a forum, a mailinglist, anything) then that is a very good reason to not use the product in question.

  • I am getting an error when I run parameterized java program in Eclipse 3.1

    When I tried to compile an example, java app, I this error.
    I checked, the jre it is using is 1.5.
    Could any one you suggest how to resolve this and why this problem?
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         The type ArrayList is not generic; it cannot be parameterized with arguments <String>
         Syntax error, parameterized types are only available if source level is 5.0
         The type ArrayList is not generic; it cannot be parameterized with arguments <String>
         Syntax error, parameterized types are only available if source level is 5.0
         Type mismatch: cannot convert from int to Integer
         Incompatible operand types Integer and int
    Code:
    http://www.anyexample.com/programming/java/java_arraylist_example.xml
         at Ex01.main(Ex01.java:13)
    Edited by: xmlcrazy on Aug 23, 2009 6:59 PM

    I got it. It is under windows/preference/java/compiler/compatibility. This fixes the problem.

  • How to run a standalone java program with JRC to display/run a report

    Hi All,
    I am new to this forum.
    I am trying to run a java program developed using JRC to run a report created using Crystal Report XI. I stucked because not knowing how to run that java program.
    Can anyone help me? or
    can give a simple java code to do the same.
    Thanks in advance.
    Saravanakumar.

    Hi Saravana
    For the steps to run a standalone application java program with JRC to display/run a report ,please refer the following link.
    http://support.businessobjects.com/communityCS/TechnicalPapers/cr_xi_r2_jrc_deployment.pdf.asp
    You can get the sample code for standalone/desktop applications from the following link.
    http://support.businessobjects.com/communityCS/FilesAndUpdates/crxi_r2_jrc_desktop_samples.zip.asp
    Please do revert in case of any queries.
    Thanks
    Soni

  • Error message when try to run copied java program

    Hi Java Guru,
    Can somebody help me with this issue ?
    I was copy my java source from java_ulangan2 to java_ulangan20, when i tried to run the java program, i get an error message.
    Below is the error message:
    05/01/2010 1:02:42 PM /userOut/deploy (com.sap.ide.eclipse.sdm.threading.DeployThreadManager) [Thread[Deploy Thread,5,main]] ERROR:
    [003]Deployment aborted
    Settings
    SDM host : wfmdev
    SDM port : 50018
    URL to deploy : file:/d:/DOCUME1/GunawanJ/LOCALS1/Temp/temp7843042886291622098Java_ulangan20.ear
    Result
    => deployment aborted : file:/d:/DOCUME1/GunawanJ/LOCALS1/Temp/temp7843042886291622098Java_ulangan20.ear
    Aborted: development component 'Java_ulangan20'/'local'/'LOKAL'/'0.2010.01.05.13.02.32'/'0':Caught exception during application deployment from SAP J2EE Engine's deploy service:java.rmi.RemoteException: Cannot deploy application local/Java_ulangan20.. Reason: Clusterwide exception: Failed to deploy application local/Java_ulangan20. Check causing exception for details (trace file). Hint: Are all referenced components deployed and available on the engine?; nested exception is:      com.sap.engine.services.deploy.container.DeploymentException: Clusterwide exception: Failed to deploy application local/Java_ulangan20. Check causing exception for details (trace file). Hint: Are all referenced components deployed and available on the engine? (message ID: com.sap.sdm.serverext.servertype.inqmy.extern.EngineApplOnlineDeployerImpl.performAction(DeploymentActionTypes).REMEXC)
    Deployment exception : The deployment of at least one item aborted
    I really appreciate any kind of help.
    Thanks,
    JGN

    Hi John.
    In past i have faced same problem for the same task. Take help of the Basis team provide tham .ear file name and ask then to un-deploy the file from the server cluster.
    After this deploy your application again.
    Hope this may help you.....:)
    Deepak!!!

  • Running a java program a set number of times

    This is a general question. Is it possible to make a java program run only 5 times for the sake of arguement.
    Basically I want to write a program that will give the user some flexibility when it will actually run another Java program, but I only want them to be able to say "not now' for a set number of times. When the last time comes the other program will launch. I was initially thinking of the Do Whilw loop, but this needs to work when the program is restarted.
    Program starts, it has 5 times it will run before it does something else(doesn't really matter now I think). User takes option "Not Now" and the program ends, but warns the user this will run 4 more times before you will need to do something.
    This process will repeat until the user takes the option "Ok install now" or the time limit expires and the install occurs anyway. Can someone point me in the right direction.

    ok I see so it's like one those programs that you download for free on the internet and they give you a set amount times to use it before you have to pay for it. but in this case when the number of times you use it equals 5 (or when the user clicks ok) a different java app will open automatically.
    My first thought would be to Write a Serialized object to disk using objectOutputStream that stores the number of times the application has been opened. and each time the program runs it checks for the serialized object and then you can do something like what I posted before. of course if were worried about security the user could always look for the object and erase it, if so then I guess we would have to come up with another plan of attack
    Hope this helps

  • Running a java program from an icon

    I want to run my program from an icon on my desktop. I have a .bat file that I've built a shortcut to and it works.MY GUI program does display and run when I click on the icon. The problem is that the DOS window also shows up behind my GUI.
    Is there anyway to prevent the DOS window from showing? Or is there another way to run a Java program without resorting to a DOS command line or running it through FORTE or another IDD?

    Chris's solution worked well, with one small problem. Once my GUI starts, it takes up the whole screen. Normally when I run it, it appears as a small window.
    not a big problem, I can reduce it easily after it starts. But does anyone know a way to make it come up in the reduced size it norally comes up in when I run it from my IDE?

  • Running a java program via a batch file

    I am unable to run a java program from a batch file that I created.
    spiderpackage.EntryPoint is a class file which I am trying to run with a -v option to output something.What should I do to get the output?
    echo ^<html^>^<body^>
    echo hello^<br^>
    call java spiderpackage.EntryPoint -v
    echo ^</body^>^</html^>

    This has nothing to do with java programming. Have a look at the windows help for the call command.
    The echo <html> stuff doesn't make sense. What's it for?
    The command in you batch file should be:
    java -cp . spiderpackage.EntryPoint -v
    assuming that java is in the system path, and the EntryPoint.class is in a directory called spiderpackage which is a subdirectory of your current working directory

  • Running a java program in a directory other than the current directory

    How do I run a java program that's located in a directory other than the current directory?
    There is a file Test.java in /dir1/subdir1. If my current directory is anywhere other than that directory, say /dir2/subdir2, I can compile Test.java by using:
    javac -classpath /dir1/subdir1 /dir1/subdir1/Test.java
    But when I try to run it with:
    java -classpath /dir1/subdir1 /dir1/subdir1/Test
    I get a java.lang.NoClassDefFoundError: \dir1\subdir1\Test
    Any thoughts?

    You need to specify just the name of the class you want to run. So java -classpath /dir1/subdir1 Test

  • Exception while Running a Java Program for UME.

    Hi Experts,
                           I am trying to run a java program to acess UME. Its a sample to create user but all of my samples are throwing this exception in NWDS  (Console).Can anyone tell me why is it throwing this exception .
    com.sap.security.api.UMRuntimeException: UME factory 'com.sap.security.api.IUserFactory' cannot be accessed because UME initialization has not started yet.
    Please check
            UMFactory.isInitialized() before using UME functionality.
        at com.sap.security.api.UMFactory.checkInitialized(UMFactory.java:1019)
        at com.sap.security.api.UMFactory.getUserFactory(UMFactory.java:801)
        at Search.main(Search.java:25)
    Exception in thread "main"
    Thanks in advance
    Somil

    Hi,
    Earlier i faced the same exception when i tried to call the UME form Standalone java application,To resolve this i used stateless session bean approach. i follow the Below Mentioned Steps,
    1:-- create an J2EE -- EJB module project.
    2:-- Create stateless session bean and define the require methods ,implement Local and remote interface methods  in your bean class.
    3:-- refer the UME apis in EJB Projects build path.
    4:-- Call UME in Bean class methods.Build the EJB project and Archive.
    5:--Now create an Enterprise application Project ,Include the EJB module project to your EA Project by right clicking on EA project.Build EA project and EAR file
    6:--Deploy the EAR file on your server.
    7:--Now from your standalone java application include these two projects in Project tab of your Application.
    8:--Lookup the stateless session bean in your java class by its default JNDI name ,Obtain remote or local Home interface,And execute the BEAN Method which deals with UME.
    You can also refer this tutorial in some parts of it UME apis(like IUser,UMFactory) are used in Servelets and EJB ,You can download this tutorial source from SDN for your reference.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/297f35cf-0201-0010-00b2-fe2f3e23d360
    Siddharth

  • How do we run a servlet program in eclipse

    how do we run a servlet program in eclipse.

    Not at all, because servlets require a servlet container. Some Eclipse plugins (Lomboz etc.) do provide integration with those.

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • How to run a java program in command prompt

    hi i want to run a java program from in command prompt from another directory
    i want to run a file named First in C:\Program Files\Java\jdk1.6.0_07\bin
    so when i give the command
    java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    it doesnt works it shows
    C:\>java "C:\Program Files\Java\jdk1.6.0_07\bin\First"
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Program Files\Java
    \jdk1/6/0_07\bin\First
    Caused by: java.lang.ClassNotFoundException: C:\Program Files\Java\jdk1.6.0_07\b
    in\First
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: C:\Program Files\Java\jdk1.6.0_07\bin\First. Pro
    gram will exit.

    but it prints
    C:\>java -cp "C:\Program Files\Java\jdk1.6.0_07\bin\" First
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -client to select the "client" VM
    -server to select the "server" VM
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A ; separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
    show splash screen with specified image
    C:\>

Maybe you are looking for

  • Need Help in iProcurement

    Hi OAF Guys I am working in iProcurement and (new to iProcurement) to extend the non-catalog request template for suit to our organization. One of the extension is to provide all the information regarding the Travel Schedule when one employee wants t

  • VA02 - maintain settlement rules

    Hi folks, I am trying to maintain a settlement rule within the Sales Order without the user going to the Item Level. I want to inherit the WBS element from the Header VBAK and on the save of the document automatically create the settlement rule. I ha

  • Files in NFS share not visable

    I'm trying to install Solaris 10u4 from a Netra T1-200 install server. The client is a Sun Enterprise 5000, it boots fine during the network install but gives the error "The directory you specified doen not contain a valid Solaris OS image". If I mou

  • ALV tab strip tree and container

    Hi Gurus, i have a requirement , in which a list of records are displayed as tree ALV at output and when user clicks on any of the records then in the bottom of the screen , it should display its item detials as tab strip in the same screen ( i mean

  • All data lost between 13/11/07 and 17/07/08

    When i rebooted my iMac this morning, all my data (emails, received faxes in Pagesender,-) are gone !! Is there a way to recover and what can be the reason ? thanks,