cancel
Showing results for 
Search instead for 
Did you mean: 

Error when running "Run as" Java application from NWDS

Former Member
0 Kudos

Dear All,

I am trying to run the following .java proggie...

Thanks for that. By the way, I am now trying to compile the following .java program.....

/*

  • Created on 01-Oct-2007

*

  • To change the template for this generated file go to

  • Window>Preferences>Java>Code Generation>Code and Comments

*/

/**

  • @author chris.jackson

*

  • To change the template for this generated type comment go to

  • Window>Preferences>Java>Code Generation>Code and Comments

*/

import com.sap.lcr.api.cimclient.CIMClient;

import com.sap.lcr.api.cimclient.CIMClientHandle;

import com.sap.lcr.api.cimclient.CIMOMClient;

import com.sap.lcr.api.cimclient.ClientFactory;

import com.sap.lcr.api.sapmodel.SAP_AppServJCODestination;

import com.sap.lcr.api.sapmodel.SAP_JCODestination;

import com.sap.lcr.api.sapmodel.SAP_JCODestinationAccessor;

import com.sap.lcr.api.sapmodel.SAP_MsgServJCODestination;

import com.sap.mw.jco.JCO;

import com.tssap.dtr.client.lib.protocol.URL;

public class sldpoke {

public void main() {

ClientFactory factory = ClientFactory.newInstance();

try {

final URL url = new URL("http://ex1d002a.eu.unilever.com:58300/sld/cimom");

String sldUsername = "cjacks01";

String sldPassword = "password";

CIMOMClient cimomClient = factory.createClient (url, sldUsername, sldPassword);

CIMClient cc = new CIMClient(cimomClient);

CIMClientHandle cch = (CIMClientHandle) cc;

SAP_JCODestinationAccessor jcoAccessor = new SAP_JCODestinationAccessor(cc);

SAP_JCODestination[] jcoDestinations = jcoAccessor.enumerateSAP_JCODestinationInstances();

JCO.Client jcoClient = null;

String user = null;

String pwd = null;

// iterate over all destinations

for (int i = 0; i < jcoDestinations.length; i++)

{

SAP_JCODestination jcoDestination = jcoDestinations;

user = jcoDestination.getLogonUser();

pwd = jcoDestination.getLogonPwd();

if (jcoDestination instanceof SAP_AppServJCODestination)

{

SAP_AppServJCODestination jcoDest = (SAP_AppServJCODestination) jcoDestination;

jcoClient = JCO.createClient(jcoDest.getLogonBCClient(),

user,

pwd,

jcoDest.getLogonLanguage(),

jcoDest.getAppServHost(),

jcoDest.getAppServNumber());

}

else if (jcoDestination instanceof SAP_MsgServJCODestination)

{

SAP_MsgServJCODestination jcoDest = (SAP_MsgServJCODestination) jcoDestination;

jcoClient = JCO.createClient(jcoDest.getLogonBCClient(),

user,

pwd,

jcoDest.getLogonLanguage(),

jcoDest.getMsgServHost(),

jcoDest.getSAPSystemName(),

jcoDest.getLogonGroup());

}

}

} catch (Exception e) {

}

}

}

and I am getting the message "The selection does not contain a main type". The class contains a 'main' function so I am at a loss as to what the problem is. Any ideas how I progress?

Kind Regards

Chris Jackson.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

there must be a "static " modifier with your main method, because static allows you to call any method without having the class to be instantiated.

Regards

Abhijith Ys

former_member485701
Active Participant
0 Kudos

Hi,

Main method should always be static.

public static void main(String[] args){}

Regards,

Praveen

Former Member
0 Kudos

public static void main(String[] args){}

Former Member
0 Kudos

Hi,

The main method is wrong. It is gn as public void main() {}

It should be public static void main(String[] args){}

Regards,

Harini S

Former Member
0 Kudos

Hi! Jakson,

to run a Stand-alone Java application, we must have one main() method like...

public static void main(String args[]){ }

i can't see this main() method on your appliation.

regards,

Mithileshwar