I'm trying to run the program in this link (specifically Plotter.java).in the zip file there's an instruction on how to run them but they don't work .I've read other questions on running a java file from terminal and I've applied those solutions but none worked on this fileceven though I've run other codes without any problems (java -dir or javac ).
how can I run this program?
also I want to run it (the plotter) in eclipse console or a GUI made in eclipse
.
p.s:I havent included any code because the program has about 10 classes and also I'm new to java.
Given the exception you have posted, the issue is because you are not providing java with the correct arguments. The program requires at least three arguments which are doubles.
They are:
minX (the first argument)
maxX (the second argument)
frequency (the third argument).
From the instructions which come with it inside the .zip:
PlotEq:
java PlotEq <min-x> <max-x> <sample-rate> <Expression>
Where:
min-x: is the minimum value of x to begin plotting
max-x: is the maximum value of x to plot up to.
sample-rate: how close points are plotted to eachother. A sample rate of 0.1 is generally acceptable, it means take a sample of the graph at 0.1, 0.2, 0.3, 0.4, etc. Basically determines how much detail to include in the plot
Expression: the equation to plot
example:
java PlotEq -5 5 0.01 "sin(x)"
plots sin(x) between x=-5 and 5, taking samples every 0.01 steps in x.
The issue is because of the missing arguments for min-x, max-x and sample-rate.
I tried to see the code, it seems you need to give double in the command line while you don't, so it tries to read empty array of args. Try to write after the name of class you execute three doubles in the command line, it should work than.
If you want to run the same in eclipse, Use menu of Eclipse: Run -> Run Configurations -> Java Application -> mouse right click -> New -> Arguments -> add some arguments you need.
And please read Instructions file carefully, it explains everything.
Related
I have JAVA SDK files to interact with a third party software.
My goal is to receive the data sampled by my RaspPi sensors online/live and pass it to this software.
The issue is that, I want to run the scripts individually (each sensor has it own python code file), because of different time cycle (sample,calc....) of everyone of the sensors.
the script are in form of:
Initialization of GPIO
Functions declarations
Var declaration
Infinite LOOP of sampling, calculating (by functions) & printing new line (the data) to screen - usually a floating number.
For now, as I understand, I need to start the python once at start of my java, by thread/process/sub-process.... while every time new line printed it supposed to parse to AtomicInteger. and that continue running on background.
Then on the Java I have another infinite loop that inside:
1."get" each one of the AtomicIntegers.
2."pass" it..
and again "get" -> "pass" (this loop while have one second cycle).
this is my first time asking a question, i hope i explained myself correctly :)
thanks in advance to all answers.
Gil
I'm trying to communicate Java and Cobol. I need to call a Java program (with paramaters) from Cobol.
I read some documentation from Microfocus:
http://supportline.microfocus.com/documentation/books/nx40/dijafc.htm
http://supportline.microfocus.com/documentation/books/nx40/dijaco.htm
But I didn't find a real solution, because I need to call an entire program and not a Java Class.
Thanks in advance.
Below is a sample program that will launch an EXE from within a COBOL97 application.
Check CallEXE demo in http://www.netcobol.com/support/code-samples/
When it comes to Microfocus...
One can not CALL an EXE from a Micro Focus INT or GNT, but you can CALL a Non-mainframe program (Micro Focus dialect in MFE) and issue a shell to DOS and from there either execute a command line that executes the EXE or execute the EXE file directly passed on the Micro Focus CALL (x'91' function code =35).
Also, you will not get back any passed parameters since once the DOS shell is closed, no parms can be returned. So the best way to get parms back is to write them to a file.
I am including a sample program that shows this x'91' FC=35 call. As you can see, you can execute a batch file or a command or an EXE directly.
Working-Storage Section.
1 Cmd-Line-Str.
2 Pic X(45)
* value 'RUN $IMSDIR\PCIMS RUNIMS BMP,DBUTIL,DEMO001T'.
* value 'run lorince'.
value 'dir c:\ /o > d.d'.
2 N-1 Pic X Value Low-Value.
1 Call-Func Pic X Comp-X Value 35.
1 Result Pic X Comp-X.
1 Cmd-Line-Len Pic X Comp-X Value 0.
Procedure Division.
P1.
Display Cmd-Line-Str upon Command-Line
Call x'91' using Result, Call-Func, Cmd-Line-Len
If Result = Zeroes
Display 'Call worked'
End-If
Goback.
I hope the post gives you some more information, I have only mainframe knowledge and haven't tried any of this above.
The link you posted explains very well about how we can instantaite a java class. If you are concerned about parameters, then write the Java Class with parameteric constructor and pass the parameters while you instantiate the Class from Cobol.
If you are confused about Java Class and Java Program, then you need to know that Java programs are compiled into .class files at the most you have executable jars containing .class files. But there is nothing like .exe for java.
I am writing part of a PHP web application (which will be used in a high school bug finding contest) where the user must find bugs in a given Java program. As a part of this, when the Java program executes, we want to highlight the lines of the source of the Java program where the code has executed. To do this, all we need are the line numbers of the source that have been executed, that is, the code path (or is it called code coverage?). We will highlight the lines in the source file using the line numbers.
We will be using PHP's shell-exec() to execute the Java program and the tool to get the code path (whatever that will be). What is the easiest way of getting the line numbers of code path?
Thank you very much!
Here is a picture that describes what we would like
PHP interperts the code, which means it runs over the source each time you run the program. This has the benefit of blowing up as the code is read (which makes line number printouts trivial); however, it often is expensive in other ways, as you cannot optimize deeply (or do any pre-runtime error checking).
Java compiles its code into a JVM assembly language called "bytecode." This means that what is running doesn't generally have access to (or even use) the source code. That said, there are techniques. A compiled Java class has the ability to add "extra data" and one of those "extra data elements" is a line number table, which is an index allowing someone running the assembly to "look up" the line number as the compiler recorded it.
This generally works ok, with the considerations that: compilers often don't mark up every instruction, the source code may not be available, optimization might make certain inner chunks of code not function in ways that facilitate pointing to the input code text.
How code coverage tools "fix" this is that they generally insert into the code (at the assembly level) a large number of commands that effectively act as logging statements to a format that allows the tool to determine which path through the code was actually followed. This is then mapped back through the line number table as best as possible and then used to highlight lines within the original source file.
If you want something with finer resolution (something that can process which portion of a line was executed) then you need to dig deeper. Eventually you might even consider writing your own compiler (or compiler extension) which will store your own custom line number table that overcomes the shortcomings of the current solutions.
Tricks like throwing exceptions (as Shiven has mentioned) and parsing out the line number do work; however, they pollute your code with odd exception processing for items that really aren't exceptional, just to "get the line number". Due to the code clutter and the generally poorer runtime performance of exceptions, I tend to avoid such solutions (but they do work).
Anyway, hopefully this will give you a view as to why it doesn't always work exactly the same way as PHP.
You could get a linenumber if you compile the program with the -g option, do a printStackTrace(), capture the trace output and extract the linenumber from there.
Take a look at Cobertura. It computes coverage and stuff like that, and if it doesn't already do it, it should be relatively easy to add the line number collecting to it.
There's a very hackish attempt to do that, but that's so slow that you may not be able to use it in production https://bitbucket.org/jowu/myriapod/wiki/Home
I have never done or seen anything like this but it does seem like an interesting problem. My thought would be to use the java debugger (jdb) to run the code, rather than just the java command.
You can step through the code line by line (via the step command in jdb) and each time a line executes its line number is spit out. This would require a little help from the PHP side (it would have to parse the line number as well as execute the next step command) but the line numbers are there. Here is a sample output from a very basic java program.
Java (TestClass.java)
public class TestClass {
public static void main(String[] args) {
System.out.println("foo");
System.out.println("bar");
}
}
jdb (jdb TestClass after running javac TestClass.java)
Initializing jdb ...
> stop at TestClass:3
Deferring breakpoint TestClass:3.
It will be set after the class is loaded.
> run
run TestClass
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint TestClass:3
Breakpoint hit: "thread=main", TestClass.main(), line=3 bci=0
3 System.out.println("foo");
main[1] step
> foo
Step completed: "thread=main", TestClass.main(), line=4 bci=8
4 System.out.println("bar");
main[1] step
> bar
Step completed: "thread=main", TestClass.main(), line=5 bci=16
5 }
main[1] step
>
The application exited
Try referring to this link JVMDI
You can try accessing the values of the program counter and then map it onto the lineNumberTable .
OR
I think JVMDI has a method which can access the line number of the executing code.I'm not sure of the latter,refer the to the link above and hope it helps.
I have a class (called LogCopy) I've written which when I run it in Eclipse with the 4 parameters it's supposed to have, in the correct format, surprise, surprise, runs perfectly fine. The trouble is, I need to .jar it up to put onto a live system & that's where it gets squirly. The parameters are 2 datetime stamps & 2 filenames. It's being developed & executed on a Windows system so the parameters I've supplied to test with are:
2011-03-20|10:21:20 2011-03-20|10:21:21 F:\somepath\logfile.txt F:\somepath\logfileoutput.txt
Now, putting those into a Run Configuration in Eclipse gets the desired response. If I remove a parameter or put in a value that isn't a valid date or a readable input file or a locked output file, it throws exceptions as I've set it up to do, all well & good. But when I jar it up using maven, and run it with the 4 parms as they're supposed to be I get the cryptic
The filename, directory name, or volume label syntax is incorrect
Strangely though I still get the expected error messages when I deliberately mess up the parameters, so
java -jar LogCopy-0.0.1-SNAPSHOT-jar-with-dependencies.jar parm1 parm2 parm3 parm4
gets an error log entry for each thing that's wrong about the parameters - that the dates aren't valid dates, the filenames aren't referring to files that can be used, and a little precis of the command's syntax so the user can correct what they've entered.
How come the valid filenames are giving this weird error message? I've tried entering the filenames in various formats, using forward slashes, backslashes, escaped backslashes, all sorts, but they all give the same (non programmed by me) error message. What gives?
I sussed it - & you're all going to think I've been a total noob about this & you'd be right. One of those "D'OH!!" moments. Turns out the parms only work properly if passed in as strings in double quotes, so:
java -jar LogCopy.jar "2011-05-04|10:05:23" "2011-05-04|10:05:26" "C:\dir\fromfile.txt" "C:\dir2\tofile.txt"
works, while without the double quotes Java mis-parses the parameters & appears to take part of the date as a filename.
I have been working on a developmental biology project marking various nuclear markers along with a DAPI stain to determine percentage of marker expression. I have found that the ImageJ plugin ITCN (http://rsbweb.nih.gov/ij/plugins/itcn.html) works great for each marker when also using the CLAHE program. My problem is that I have around 6000 images to analyze and I would love to be able to automate the process. I have recorded a macro such as the following (which can itself be looped to individual image files) :
open("image");
run("8-bit");
run("CLAHE");
run("ITCN ");
close();
but the ITCN icon wont start analyzing automatically, nor is there an easily programmed short cut to do the job. I am completely ignorant to any Java programming and I would love to know if there is anyway to get around this likely easy problem.
Thanks in advance
Michael
The ITCN plugin is implemented as a PlugInFrame and its settings are not recordable, as you have discovered. However, looking at the source, it seems that the plugin just uses another class called ITCN_Runner once it has gathered the options, which you should be able to call programmatically.
However, you can't do this from the macro language. Probably the easiest alternative is to use ImageJ's built-in Javascript scripting. For example, start up the Macro Recorder as usual, but select "JavaScript" in the top left. Then the first couple of commands appear for me (with some reformatting for clarity) as:
imp = IJ.openImage("/home/mark/test.tif");
IJ.run(imp, "8-bit", "");
IJ.run(imp,
"Enhance Local Contrast (CLAHE)",
"blocksize=127 histogram=256 maximum=3 mask=*None* fast_(less_accurate)");
Then if you look at the source code of the ITCN plugin you can see how to create the ITCN_Runner class and run it - for example:
runner = new ITCN_Runner( imp,
1, /* width*/
5.0, /* minimum distance */
0, /* threshold */
false, /* detect dark peaks */
null /* mask ImagePlus */ )
runner.run()
That produces output in another window, which has the same name but with "Results " prefixed.
Thanks Marc.
Unfortunately there is an error that results when I run the java scrip.
ReferenceError: "ITCN_Runner" is not defined. (#6) in at line number 6
It says there is an unknown source in the line of the ITCN runner. I can't tell if this is a problem with the code, the fact that I simply copied and pasted yours into the recorder without going into the source code to do so, or the ITCN runner itself.
Thanks again,
Michael