I am calling as400 system from Java. I am able to connect to a program of as400 system but not able to get the output data. It is giving me empty message.
AS400 as400 = new AS400("as242g.na.sysco.net", "dprint", "dprint");
System.out.println(as400);
ProgramParameter[] parameters=new ProgramParameter[4];
AS400Text opcoText=new AS400Text(3,as400);
AS400Text emoptyText=new AS400Text(1,as400);
AS400Text indicatorText=new AS400Text(1,as400);
parameters[0]=new ProgramParameter(opcoText.toBytes("056"));
parameters[1]=new ProgramParameter(emoptyText.toBytes(" "));
parameters[2]=new ProgramParameter(indicatorText.toBytes("Y"));
parameters[3] = new ProgramParameter(10);
String fullProgramName = "/QSYS.LIB/SCSUINT.LIB/DPIM10CL.PGM";
System.out.println(fullProgramName);
ProgramCall programCall=new ProgramCall(as400);
try {
programCall.setProgram(fullProgramName,parameters);
if (programCall.run()) {
System.out.println("run");
AS400Text text1 = new AS400Text(10,as400);
String message=(String) text1.toObject(parameters[3].getOutputData());
System.out.println(message);
}
else {
System.out.println("false");
}
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AS400SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ErrorCompletingRequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ObjectDoesNotExistException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Could someone please help what changes need to be done to get the desired output result
Related
i am trying to generate a snapshot from a video using the following code. and it is working fine running as a java application on sts.
public class VideoThumbTaker {
public static void main(String[] args)
{
FFmpegFrameGrabber g = new FFmpegFrameGrabber("/home/anupam/Downloads/jk.mp4");
g.setFormat("mp4");
try {
g.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (int i = 0 ; i < 1 ; i++) {
try {
ImageIO.write(g.grab().getBufferedImage(), "png", new File("/home/anupam/Downloads/" + System.currentTimeMillis() + ".png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
g.stop();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
using maven dependency
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>0.8</version>
</dependency>
after deploying a war file.the following code gives Error loading class org/bytedeco/javacpp/Loader
#RequestMapping(value = "menu9data", method = RequestMethod.POST)
public JSONObject view(#RequestPart(name = "file", required = false) MultipartFile image,#Valid MenuData model, BindingResult results) {
String name1;
FFmpegFrameGrabber g = new FFmpegFrameGrabber("/home/anupam/Downloads/"+name1); //Error
g.setFormat("mp4");
try {
System.out.println("enterss");
g.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (int i = 0 ; i < 1 ; i++) {
/* try {
// ImageIO.write(((Object) g.grab()).getBufferedImage(), "png", new File("/home/anupam/Downloads/"+name1+"snap"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
try {
g.stop();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I'm trying to access the messaging metrics provided by Cassandra from Java using JMX. I get the correct results when I use the following query with swiss java knife
java -jar sjk-plus-0.4.2.jar mx -s localhost:7100 -mg -all -b org.apache.cassandra.metrics:type=Messaging,name=* -f Mean
org.apache.cassandra.metrics:type=Messaging,name=CrossNodeLatency
1331.0469921040174
org.apache.cassandra.metrics:type=Messaging,name=datacenter1-Latency
1331.1071897694487
However, with the following Java code I get a javax.management.InstanceNotFoundException: org.apache.cassandra.metrics:type=Messaging exception.
JMXServiceURL url = null;
try {
url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:7100/jmxrmi");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JMXConnector mConnector = null;
try {
mConnector = JMXConnectorFactory.connect(url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MBeanServerConnection mMBSC = null;
try {
mMBSC = mConnector.getMBeanServerConnection();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ObjectName mObjectName = null;
try {
mObjectName = new ObjectName("org.apache.cassandra.metrics:type=Messaging");
} catch (MalformedObjectNameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Set<ObjectName> myMbean = null;
try {
myMbean = mMBSC.queryNames(mObjectName, null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
System.out.println((mMBSC.getAttribute(mObjectName, "*")).toString());
} catch (AttributeNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstanceNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MBeanException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReflectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Could someone please explain where am I making a mistake?
Swiss Java Knife seems to accept an ObjectName wildcard (or pattern) as:
org.apache.cassandra.metrics:type=Messaging,name=*
but your code is simply looking up a non-pattern MBean as:
org.apache.cassandra.metrics:type=Messaging
Change your code to:
Use the pattern
queryNames will return a Set of matching ObjectNames, so iterate through the set and query each one.
You need to specify a string array of actual MBean attribute names, not "*" as in your code. (It would be nice if that was supported)
Something like:
mObjectName = new ObjectName("org.apache.cassandra.metrics:type=Messaging,name=*");
Set<ObjectName> names = mMBSC.queryNames(mObjectName, null);
for(ObjectName on: names) {
System.out.println(on + "\n" + mMBSC.getAttribute(on, "Mean").toString());
}
I want to find out differences between two revisions using org-netbeans-lib-cvsclient-RELEASE712.jar.
any working example?
DiffCommand diffCommand = new DiffCommand();
diffCommand.setRecursive(true);
diffCommand.setRevision1("rel-2230");
diffCommand.setRevision2("rel-2240");
diffCommand.setFiles(new File[]{new File("D:/test/")});
diffCommand.setBuilder(new SimpleDiffBuilder(em, diffCommand));
try {
System.out.println(diffCommand.getCVSCommand());
cvsClient.executeCommand(diffCommand, opts);
Set files = cvsClient.getAllFiles(new File("D:/test/"));
} catch (CommandException | AuthenticationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I was wondering why my file is not updating to dropbox. Currently it only creates the an empty file.
final String TEST_FILE_NAME = DateTime + ".txt";
DbxPath path = new DbxPath(DbxPath.ROOT, TEST_FILE_NAME);
try {
if (!FileSystem.exists(path)) {
newFile = FileSystem.create(path);
try {
newFile.writeString("Hello world!");
} finally {
newFile.update();
newFile.close();
}
}
} catch (DbxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Solved: I never unlinked my dbxacc and kept relinking, causing errors to show up! Silly mistake.
i'm using this code:
if(!facebook.isSessionValid()) {
try {
String jsonUser = facebook.request("me");
obj = Util.parseJson(jsonUser);
String id = obj.optString("id");
String name = obj.optString("name");
tv1.setText("sodfnsdf");
} catch (MalformedURLException e) {
tv1.setText("1");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
tv1.setText("2");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FacebookError e) {
tv1.setText("3");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
tv1.setText("4");
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
tv1.setText("Error");
}
i've searched online and in stackoverflow, but cannot find the answer to my question, i only found very similiar questions but different in some ways..
Hey you need to call facebook.authorize method
if(!facebook.isSessionValid()) {
facebook.authorize() }
For more information you can refer this link. I think it will help you.
Visit http://www.techrepublic.com/blog/app-builder/integrate-facebook-logins-in-your-android-app/296