could not find main class in Saxon Xquery - xquery

java -cp saxon9he.jar net.sf.saxon.Query only yields the following message:
could not find main class net.sf.saxon.Query
I have read in other threads that this is the proper command for XQuery mode in Saxon so what else could I be doing wrong?

I'm a little surprised by this message, because normally when you get the classpath wrong, you get a quite different message: something like
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/saxon/Query
It could be that you're using some command line tool which tries to make the message more friendly.
Anyway, from the information given, the most probable explanation is that saxon9he.jar does not exist in the current directory.

Try to specify full path to your saxon9he.jar, for example, for me worked the following command when initially I had the same error, as you described:
java -cp "C:\SaxonHE9-7-0-5J\saxon9he.jar" net.sf.saxon.Query your-xquery-file.xq

Related

command line compiling generates bigger file than the online version

I am testing google closure compiler on command line.
I took the latest version :
java -jar closure-compiler.jar --version
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20190618
Built on: 2019-06-21 17:24
I am generating a compressed version of my javascript like this :
java -jar closure-compiler.jar my_script.js > out.js
The problem is that the generated code is bigger than the one I get when I use the online service at https://closure-compiler.appspot.com/home
I noticed that the command line version added, at the beginning, the following code :
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,c,b){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(c.call(b,f,e,a))return{i:e,v:f}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in b||(b[e]={});b=b[e]}a=a[a.length-1];d=b[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:c})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
I do not have such a code in my script: Where does it come from ?
how can I produce the same output as the online version ?
To get the compiler command line work as the web service, I just added an option :
--language_out=ECMASCRIPT_2015
This is likely a discrepancy between the settings on the web service and the ones you're using locally.
Have a look at a Closure Compiler: Flags and Options to see what settings you might prefer.
If you'd share your source, it'd be possible to try and help you narrow down the options.
As for the extra code, I believe it is at least partially a polyfill for Array.prototype.find (aka [].find), which I assume is in your code?
If so, that's Closure injecting code to improve your cross browser compatibility.

Asterisk-Java can't find fastagi-mapping.properties

I'm using Asterisk and I'd like to emit a call from my Java app and then use an AGI script to control what happens. So I've got a first class that contacts the Asterisk server and uses an OriginateAction to start the call (this works well) and an AGI server that runs and should serve AGI requests. Though, it doesn't work because it can't find the fastagi-mapping.properties file.
Here is my fastagi-mapping.properties:
alertcall.agi = AlertCallScript
(It only has one case.)
In the same folder, I have AlertCallScript.java (and asterisk-java.jar) that I compile like this:
javac -cp asterisk-java.jar:. AlertCallScript.java ExamplesAsteriskSettings.java
And then I start my AGI server using this (found in the doc):
java -cp asterisk-java.jar:. -jar asterisk-java.jar
When I emit my call, I get the following error in the AGI server output:
Jun 13, 2018 6:28:12 AM org.asteriskjava.fastagi.ResourceBundleMappingStrategy loadResourceBundle
INFO: Resource bundle 'fastagi-mapping' not found.
Jun 13, 2018 6:28:12 AM org.asteriskjava.fastagi.internal.AgiConnectionHandler run
SEVERE: No script configured for URL 'agi://localhost/alertcall.agi' (script 'alertcall.agi')
And I don't know why... I've been looking into this for more than an hour and I probably made a stupid mistake, though I can't find it.
Notes :
I use my classpath java-asterisk.jar:. to be able to have asterisk-java and the current folder, which contains the fastagi-mapping.properties file, so the file should be found without any problem within the class path.
I have already try to delete and recreate the file, it didn't change anything.
Please suggest.
Part of the problem is probably trying to use -cp and -jar in the same java command, this is not supported and there are a number of questions on Stackoverflow about that (here is one).
You can use something like
java -cp asterisk-java.jar:. DefaultAgiServer
to start asterisk-java's DefaultAgiServer specifically (which is what specifying -jar asterisk-java.jar is going to do anyways, if I remember the entry in the manifest correctly).

"A JNI error has occurred, please check your installation and try again" Sat4J

I wrote a java programm using Sat4J and it works fine. Now I want to export it as a jar-File, but when I execute it, it allways says
"A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/sat4j/specs/TimeoutException"
I don't have much experience with more then one package. So my structure is that I have one package with 4 classes I wrote and one package with 3 Sat4J classes. I don't even know if the error occurs because of sat4J or the different packages.
Does anyone have a clue what I can do? Thanks.
You need to add all Sat4j classes (from org.sat4j.core.jar for instance) in your jar.
Your favorite IDE usually provides a way to automatically include all dependencies with your code in a single jar.

syntax error, unexpected T_USE, expecting T_FUNCTION in my SauceLabs test case

I tried following the SauceLabs PHP tutorial: https://docs.saucelabs.com/tutorials/php/
I tried to make it run on Windows. So I followed every step until I have to run this command:
vendor\bin\phpunit.bat WebDriverDemo.php
This generates an error: Parse error: syntax error, unexpected T_USE, expecting T_FUNCTION in C:\xampp\htdocs\sauce-tutorial\vendor\sauce\sausage\src\Sauce\Sausage\WebDriverTestCase.php
on line 6
So I tried looking at WebDriverTestCase.php on line 6 and this is the code:
namespace Sauce\Sausage;
abstract class WebDriverTestCase extends \PHPUnit_Extensions_Selenium2TestCase
{
use TestCase; // this is line 6
}
Whats wrong with this code? I changed nothing, I only tried to run what the tutorial suggests. Any ideas?
I don't use PHP but on the basis of what I found with a Google search, I'd suggest making sure you are running the code with PHP 5.4 or later. In the cases I found on the web using an older version of PHP seemed to be the cause of that error.

javacc testing Simple1.jj

If you see my other question, you will now better my goals. Take a look at: https://stackoverflow.com/questions/19510039/from-regex-to-parser-generators .
As I'm trying to be a good boy, I'm reading the README (see https://java.net/projects/javacc/sources/svn/show/tags/release_60/examples/SimpleExamples?rev=555 ).
Run javacc on the grammar input file to generate a bunch of Java files that implement the parser and lexical analyzer (or token
manager):
javacc Simple1.jj
Now compile the resulting Java programs:
javac *.java
The parser is now ready to use. To run the parser, type:
java Simple1
My try:
D:\tests\javacc\simple1>javacc ..\Simple1.jj
Java Compiler Compiler Version 6.0_beta (Parser Generator)
(type "javacc" with no arguments for help)
Reading from file ..\Simple1.jj . . .
File "TokenMgrError.java" does not exist. Will create one.
File "ParseException.java" does not exist. Will create one.
File "Token.java" does not exist. Will create one.
File "SimpleCharStream.java" does not exist. Will create one.
Parser generated successfully.
D:\tests\javacc\simple1>javac *.java
SimpleCharStream.java:474: error: non-static variable this cannot be referenced from a static context
static void setTrackLineColumn(boolean trackLineColumn) { this.trackLineColumn = trackLineColumn; }
^
1 error
My java version:
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
I'm sure that "these" guys known what they are doing, I'm sure I did something wrong, but what? Getting a simple error like that in the first test with javacc?
How can I fix that and continue my lecture?
I suggest using version 5.0 for now. There are a lot of changes in version 6 and these came along with some bugs. There should be an update to version 6 soon. https://java.net/projects/javacc/downloads
Will you put the code to look it or your complete call. I think, that it´s a code error or that you call a bad .java archive. For example:
I have: Mytokens.jj and javaCode.java ok? Good, you need said:
javacc Mytokens.jj
javac javaCode.java
java javaCode <test1.txt>
I give you my *.bat for the test. You create a new txt and write it:
CALL javacc nameJJ.jj
#pause
CALL javac NameJava.java
#pause
java NameJava <prueba1> salida.txt
type salida.txt
#pause
This do the test for you when you do a double-click on it if you have a copy in your javacc/bin and your practice directories.

Resources