java -jar saxon9he.jar persons.xml persons_users.xslt -o:persons_transformed.txt - saxon

I am having an XSLT to convert my xml into html format. I didn't achive any Experience about Saxon before but I'll try again and again.
This is the problem I had :
C:>java -cp saxon9he.jar net.sf.saxon.Transform -t -s:samples\date\books,xml-csl:samples\styles\books,xsl -o:c:\temp.html
Error: Main class net.sf.saxon.Transform could not be found or loaded
I did everything step by step from the Saxon Website :
https://www.saxonica.com/html/documentation/about/gettingstarted/gettingstartedjava.html
and I saw MR.Michael Kay Videos a lot before but it isn't work any way.
Can perhaps any one help me please ?

The problems are with Java, not with Saxon, in case that helps you look in the right place for documentation.
The message "Main class net.sf.saxon.Transform could not be found or loaded" is Java telling you that it can't find Saxon.
The bit of the command that tells it where to look is this:
java -cp saxon9he.jar net.sf.saxon.Transform
Here "java" is telling the operating system to load the Java virtual machine (which has succeeded). The "-cp" option is telling Java what Jar files to search for the relevant classes, and the "net.sf.saxon.Transform" part is saying what the relevant class is.
The problem is probably that there is no file called saxon9he.jar in the current working directory. Unfortunately Java doesn't give you an explicit error message for this, it just ignores this part of the command. Probably the current working directory isn't what you think it is. If you do "ls" or "dir" immediately before the "java" command, it will tell you what files are in the current working directory, which should include the saxon9he.jar file. If the JAR file is in some other directory, you can supply an explicit path, e.g. -cp c:/mike/java/saxon9he.jar.

Related

javac not recognizing external libraries

I have a working version of my project in eclipse.
I exported the project as a runnable jar.
Extracted (after converting to .zip)and tried to compile a particular java file from the command prompt
(Doing it this way since I have a project requirement, where input parameter inside that particular file can be modified and recompiled/run by users who wont have Eclipse)
I have used some external libraries( for Eg:json-simple,gson etc).They arent getting recognized , during compilation.
But if I run the class file(from the Eclipse compiled version), it gets executed properly
a)Tried to compile from root folder(using package name)
javac packageName.javaFileName.java
b) and went inside the package and compiled directly.
javac javaFileName.java
The a)part didnt compile at all saying classNotFound. The b)part started compiling but threw an error where none of the external libraries got recognized.(Getting --> error: cannot find symbol for places wherever the code/import of the external lib is used)
a)Tried to compile from root folder(using package name) javac
packageName.javaFileName.java b) and went inside the package and
compiled directly. javac javaFileName.java
The a)part didnt compile at all saying classNotFound.
Yes. javac requires you to specify a filesystem path to the (first) source(s) to compile. You appear instead to have tacked .java onto the end of the desired fully-qualified class name. Probably you want to compile from the root of the unpacked jar, specifying a correct path:
javac [options] package/name/className.java
for class package.name.className. (You can also compile from a different working directory if you specify an appropriate option, as discussed below.)
The b)part
started compiling but threw an error where none of the external
libraries got recognized.(Getting --> error: cannot find symbol for
places wherever the code/import of the external lib is used)
If the class you're compiling depends on others that also need to be compiled then javac would likely make a similar complaint about them. Either compile from the root (as in (a)), or specify the path to the source root via the -sourcepath option. Either way, there's no reason to descend into the source tree to compile.
But the external libs are actually a separate, albeit related, question. You don't need to compile these, but you do need to tell javac to use them as sources of classes. You would do that via the -classpath option, which you can abbreviate to -cp. If those were packaged in the jar itself (i.e. a "fat jar") then that should be fairly easy, something along these lines:
javac -cp .:lib/dependency1.jar:lib/dependency2.jar package/name/className.java
The "lib" part may vary, and the separator definitely differs depending on OS (on Windows it is ;, whereas on Mac / Linux / Solaris is is :, as shown).
If the external libs were not packaged into the main jar then the procedure is the same, but you might have a bigger challenge finding the needed jars. Also, such a jar is probably not runnable if you move it to a different machine. Nevertheless, you should probably look in META_INF/MANIFEST.MF, as it should contain the needed information.

Why while compiling java code through cmd it's written as filename.java and running the same file we omit filetype?

While compiling java files through cmd (ie through javac command) it is written as filename.java but to run the same program we write filename and don't add the extension. Why is extension removed in java command or extension added in javac command ? Any specific reason.
When compiling, you specify the name of one or more source files, thus the .java extension
When running you specify the class name of the main class, thus no extension.
The difference becomes even more apparent, when the class is in a package:
javac mypackage/MyClass.java
java mypackage.MyClass

How to run QAC tool from command line?

I have a C project and I would like to run QAC tool v7.0 from command line. I tried the following option,
C:\qac.exe -via <project_name.prj>
However, when I run the above command. I get an error saying the "VersionTag" is not found. The "VersionTag" string is the first line in the .prj file. I am not sure this is the right way to run this tool. Any help appreciated.
The qac -help is not giving valuable information either. The tool version is pretty old and the company 'Programming Research' behind this tool also has been renamed? to Perforce. They do not have any information about command line invocation either from the existing documentation or webpage.
The QAC utility is the "engine" part of the QAC package, corresponding to a compiler.
It won't be happy being run on command line without a number of environment variables:
QACBIN must point to the bin directory of the QAC package installation;
QACHELPFILES must point to the location of message help files;
QACOUTPUT points to the location where output files will be generated (binary .err file for each source file and textual .met file containing semantic and metric information.
The -via parameter to the command line should point at a text file containing other parameters used by the utility.
The .prj file is a package-level file defining the location of C source files being analysed plus their configuration settings files, among other things. It definitely should not be passed directly as a parameter to the QAC utility.
This should get you started, and other questions need to be more specific.

Selenium Builder test execution through SeInterpreter.jar

I have recorded a UI test with selenium builder (firefox plugin) and have saved it as a .json file.
Now I am trying to run this through commandline using SeInterpreter jar.
My command is this:
java -jar SeInterpreter.jar <path of .json test file>
I have found information here.
I have downloaded the project but have not found SeInterpreter.jar file anywhere, I have searched exclusively for the jar file as well but could not get it.
Is there any other better way to achieve this?
After some analysis and searching i finally found the SeInterpreter.jar here:
http://seleniumbuilder.github.io/se-builder/tools.html
Hope will be helpful for others with similar query.

Solr : Can post.jar be used to post files recursively within folder and subfolder

If I would like to post all the xml files in a folder then I use post.jar.
java -jar post.jar *.xml
In case if I would like to post the files recursively ( i.e post xml files under subfolder level also is there anyway to achieve this.)
If you're on a unix-like (OSX or Linux), you can do something like this:
find . -name \*xml | xargs java -jar post.jar
That'll find all .xml files in or under the current directory ('.') and pass them as parameters to the java -jar post.jar command.
find is incredibly opaque, but very useful for stuff like this.
Please think twice before using stuff under the /example directory of Solr. I use Solr from Tomcat (instead of the Jetty embedded in the start.jar) and I use URLLIB2 in Python for POSTing data to Solr. (Jetty is a production-level software, so dont worry too much about that).
So, for uploading files, consider writing it in your favorite programming language. You can implement folder recursion yourself. For POSTing files, you need libCURL , which can send HTTP GET, form POSTs, multipart POSTs etc. A C program using libCURL needs no more than 8 lines to POST a file. CURL bindings exist for all major languages, so you can recycle libCURL stuff written in C to PHP, for example.
Yes, you can!
You just need to ad the -Drecursive flag.
java -Drecursive -jar post.jar *
For further options for the flags and usage just use:
java -jar post.jar -h

Resources