How to use jmlc, jmlunit with OpenJML? - java

I have installed OpenJML tool (http://openjml.org/) for the Eclipse and was using it and it worked quite well.
However, now I need to call the jmlc and jmlunit tools from command line. As I see from the search in Internet these tools should be located at some directory of JML,I should add them to PATH and use normally by calling the corresponding commands. But once I download OpenJML I have only 3 jar files and no directory at all. Also, from the official JML page there is no other link to download some other version rather than OpenJML. It seems to me that I don't get something obvious.
So, the question is how I can find these tools to run them on command line?
Thanks in advance.

For jmlc, use the -compile flag.
You can also add it as in alias in your ~/.bash_profile:
alias jmlc="java -jar $JML_HOME/openjml.jar -compile"

Related

Graphviz's dot tool on Windows

I've created a java program to write a .dot file as I'm using Graphviz software to visualize some data.
There is nothing wrong with a code itself, but when I try to execute the following command in command prompt:
dot -Tpdf data.dot -o data.pdf
in a folder where my java code is located, I get the following error:
'dot' is not recognized as an internal or external command, operable program or batch file.
Sorry if the question was asked before, but the only similar question I found related to this problem is this one, however, it doesn't seem quite clear to me how could it be helpful in this particular case.
Any help would be appreciated. Regards.
You have to add the directory (folder) where you installed Graphviz to your PATH environment variable. How to do that depends on which version of Windows you have, but for start you can look at this answer on SuperUser.
Be aware that Graphviz is a folder (container) which contains the "dot" executable. Therefore your modified PATH should lead to dot.py and not just the container Graphviz.
These days you could use chocolaty: choco install graphviz
That seems to add it to the path as part of the install
I had the same problem, and in my case I could not use any solution that required admin privileges (e.g., changing environment variables). So I downloaded the zip file from graphviz and just changed the working directory to the install directory temporarily to call dot or spell out the path to the dot command.
E.g.:
dot -Tpdf data.dot -o data.pdf &REM Doesnt work
C:\pathTo\Graphviz\bin\dot -Tpdf data.dot -o data.pdf &REM Works

Is it possible to create a standalone JAR web app with Play Framework?

I'm trying to create a standalone JAR application, which will be executed from command line like this:
$ java -jar foo.jar --port=8080
I want to use Play Framework. Is it possible to create something like this? I want to use Java and Maven. I want to stay away from that "activators" or downloading of Play. Just plain old simple Maven dependencies. Possible?
To stay away from activator and Play download just on your dev-machine call cmd: ./activator dist (activator.bat dist for Windows) it will create a ZIP file in the target/universal/ directory containing scripts for both: Unixes and Windows within the bin directory.
So you can launch your app like (unix sample, after unzipping)
/your-app-dir/target/universal/your-app-1.0-SNAPSHOT/bin/your-app -Dhttp.port=8080
Of course, nothings prevents you from creating additional shell script/BAT file for simplicity this path
As mentioned here it is possible. Look at the documentation (Default SBT layout).
Quote from the play 2.4.0 documentation:
You also have the option of using the default layout used by SBT and Maven. Please note that this layout is experimental and may have issues. In order to use this layout, use disablePlugins(PlayLayoutPlugin). This will stop Play from overriding the default SBT layout [...]
I haven't tested it, but I think this is a good point to start at :)
P.S.: Let us know if it is possible!

installing java on a linux server

completely new to this so apologise for the question.
I have current been asked to deploy a jar on a linux server at work. I have sucessfully logged into ther server using ssh and transferred my jar on to it. However when I run any java command it says command not found.
I ran
locate java
and
locate jar
which both return, so im guessing java is installed? What do i need to do?
Thanks in advance
It sounds like your path has not been set up to fit your Java needs. You can do either of two things:
Type out the full path of where java is located, and use this full path instead of "java".
Edit your PATH to include java. Here's some information on how this is done: http://www.java.com/en/download/help/path.xml
I think you have to check to make sure that java is installed and the path for it is set too.
Whe you type locate jar it's most likely going to return any other jar including the one you have just added. To know if java is installed, you should instead use the following command java, if the result is something like the program cannot be found... then it means there is not java. You could also use java -version which will also tell you which version is installed. If it's for running purposes then you will be good with that.
First try the command which java, it would show you if you have java installed if not download it and install,run it. Then you can run the jar file as per you requirement. This link shows you how to install and configure java.
http://www.java.com/en/download/help/linux_install.xml
Thanks & Regards,
Alok Thaker

no output when .jar is executed

I built an application in Netbeans 6.8 and made project.jar file. When I run it, it works only on my computer, but not on any other computer. However, when I made any simple application, that doesnt use any libraries, it works fine on any computer.
Is there any way, how to invoke some error message, where is the problem?
My project use R 2.9.2, so I install this version on other computer and set the System Path variable exactly same. Other libraries listed in lib directory are: AbsoluteLayout.jar,DatePicker-V0.99-2006.09.01.jar,jcommon-1.0.16.jar,jfreechart-1.0.13.jar,jmathplot.jar,JRI.jar,pdf-renderer-1.0.5.jar
Thank you
You don't get any message at all? What do "works" and "not works" look like?
You sound like another person who hasn't taken the time to learn how to do things by hand on the command line without an IDE. I'd recommend doing that. Open a command shell and type in the java -jar -cp ... foo.jar command to run your stuff. The messages you get back will be educational.
Note the -cp command line argument. That's how you add your JARs to the CLASSPATH properly.
I solved this problem as follows, maybe it will help someone.I add 2 paths in PATH system variable:
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH.
you must add both paths, to jri.dll and r.dll, in my case it were these:
C:/Program Files/R/R-2.9.2/bin/;C:/Program Files/R/R-2.9.2/library/rJava/jri/;
I have added these lines already, but with different different slash. So be careful, you must use it / not \ to define path!!!

Can I add classes to sun's rt.jar file?

I downloaded the Javax.mail package. I have jdk1.6.0_11.
Problem is...I cannot get javac or java to find those classes!
I can get apps to compile using JCreator LE ( by adding the mail jar
to its search list ) but, when I try to run the app in a command window,
it fails.
Can I add these new classes to the rt.jar without
hurting my jdk installation?
I know java has it wired up to look there for classes.
(And, the mail classes are inside a javax package - seems like
they could reasonably be added to the javax folder in rt.jar..
Thanks!
Phil D'
No you can't, nor should you.
Instead, figure out the problem with your classloader (probably paths?). You'll need that for the next library you need to access.
Messing with rt.jar means you can't run on any other JVM.
You should either specify the jar file in your classpath: preferably on the command line with the -cp option, but possibly with the CLASSPATH environment variable.
Alternatively, you can specify its directory in the java.ext.dirs system property. For more details, see the documentation for the extensions mechanism.
You shouldn't be messing around with rt.jar. That's very definitely not the way to make extra jar files available - it's akin to trying to add Microsoft Word to the Windows kernel ;)
Adding things to rt.jar seems like a bad idea, even though its possible and easy to accomplish.
Try compile your application from the command line like this:
javac -cp <path_to_3rd_libs>/jarfile.jar . MainClass.java
If the compiler still complains about the javax.mail package try to unpack/examine the jar file to see that javax.mail package (and its expected content) is there.
(On windows its easy to examine a jar file using 7zip.)
Most definitely no.
If you post the command you are running from the command line we will be able to point you on the right direction, but most likely you are just missing a classpath parameter.
java -classpath /path/to/mail.jar MyClass
You need to understand the CLASSPATH concept which allows you to add individual classes and jar files containing classes to the "universe" of defined classes available for the code you want to compile and/or run. It is similar in idea to the PATH variable in the Windows world.
For the Windows command line this is the documentation:
http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
The Java Tutorial surprised me by not being well-written for this particular concept:
http://java.sun.com/docs/books/tutorial/essential/environment/paths.html
You most likely need something along the lines:
C:> set CLASSPATH=c:\javamail\first.jar;c:\javamail\second.jar
after which both java and javac should know about these classes

Categories