How to run Clojure tests on Windows? - windows

I put Clojure in C:\clojure-1.1.0, and start the REPL by:
java -cp clojure.jar clojure.main
In \test\clojure\test_clojure, there are a bunch of test files.
How to run these?
For example, I tried:
java -cp ......\clojure.jar clojure.main data_structures.clj
And it didn't work.

Two choices:
Once the REPL starts you can manually load the file with:
(load-file "\data_structures.clj")
You can pass a command-line option telling it to load/eval a file upon boot:
java -cp clojure.jar clojure.main -i \data_structures.clj -e "(do-stuff)"

We use (clojure 1.2):
java -cp "./target/***-0.1-jar-with-dependencies.jar;src/clojure" jline.ConsoleRunner clojure.main run.clj
I think with tests you can use similar way.

Related

How to start osgi console (Equinox)

I'm trying to start an OSGi console in Windows 7.
I used this statement on a terminal window:
java -jar org.eclipse.osgi.jar -console
But it doesn't work that is nothing does happen nor doesn't appear prompt osgi>. And typing on keyboard is ineffective except for ^C that makes to reappear usual terminal prompt.
Anyone has any suggestion?
Starting from Equinox 3.8.0.M4, it has a new console. So you need also these four bundles for it to run properly.
org.eclipse.equinox.console.jar
org.apache.felix.gogo.shell.jar
org.apache.felix.gogo.command.jar
org.apache.felix.gogo.runtime.jar
These jar files can be found in your Eclipse installation folder under 'plugins' folder. Copy these jars and put them in the same folder with your org.eclipse.osgi.jar and it would look like:
somedir/
configuration/
config.ini
org.eclipse.osgi.jar
org.eclipse.equinox.console.jar
org.apache.felix.gogo.shell.jar
org.apache.felix.gogo.command.jar
org.apache.felix.gogo.runtime.jar
Then edit config.ini as:
osgi.bundles=org.apache.felix.gogo.runtime#start, org.apache.felix.gogo.command#start, org.apache.felix.gogo.shell#start, org.eclipse.equinox.console#start
After doing this, run java -jar org.eclipse.osgi.jar -console in your command line and the OSGi console will start.
Reference Bug 371101
UPDATE 06/2022:
the list of required bundles got longer in the meantime:
osgi.bundles= \
org.apache.felix.gogo.runtime_1.1.4.v20210111-1007.jar#start, \
org.apache.felix.gogo.command_1.1.2.v20210111-1007.jar#start, \
org.apache.felix.gogo.shell_1.1.4.v20210111-1007.jar#start, \
org.eclipse.equinox.console_1.4.500.v20211021-1418.jar#start, \
org.eclipse.osgi.services_3.10.200.v20210723-0643.jar#start, \
org.osgi.util.function_1.2.0.202109301733.jar#start, \
org.osgi.util.promise_1.2.0.202109301733.jar#start, \
Note that you can reference the org.eclipse.osgi directly in the plugin folder. And if you do so, your configuration folder is in the plugins folder!
java -jar plugins\org.eclipse.osgi_3.18.0.v20220516-2155.jar -console
The equinox built-in console is deprecated and disabled since version 3.8. If you use a newer version, you should use the osgi.console.enable.builtin=true property. See http://hwellmann.blogspot.hu/2012/08/new-osgi-console-in-equinox-380.html.
You can set these properties as system properties. Your command will be:
java -Dosgi.noshutdown=true -Dosgi.console.enable.builtin=true -jar org.eclipse.osgi.jar -console
This worked for me with 3.8. I have just tried it with 3.10 but it does not work. I guess the builtin console is removed completely.
You should use the gogo console that has become a de-facto standard. You can find information about it at the link above.
You can also change the directory where the eclipse plugins reside and issue a command similar to:
java -Dosgi.bundles=.\org.apache.felix.gogo.shell_1.1.0.v20180713-1646.jar#start,.\org.apache.felix.gogo.command_1.0.2.v20170914-1324.jar#start,.\org.apache.felix.gogo.runtime_1.1.0.v20180713-1646.jar#start,.\org.eclipse.equinox.console_1.3.100.v20180827-1235.jar#start -jar org.eclipse.osgi_3.13.100.v20180827-1536.jar -console
This will start the osgi console

How do I run PigUnit on the command line

It isn't clear to me how to run PigUnit on the command line. I've seen some documentation that mentions some interaction with JUnit, but I don't have much experience with it.
So, if I have pigunit.jar, junit.jar and my PigUnitTests.jar in the same folder, how do I run PigUnit on the command line?
Using pig-0.10.0
You actually want to run jUnit, so assuming your jars are in the current directory, use:
java -cp ./pigunit.jar:./junit.jar:./PigUnitTests.jar org.junit.runner.JUnitCore <Your.Test.ClassName>

How run mahout in action example ReutersToSparseVectors?

I want run "ReutersToSparseVectors.java". I can compile and created JAR file without problem.
I compiled this file by below command:
javac -classpath hadoop-core-0.20.205.0.jar:lucene-core-3.6.0.jar:mahout-core-0.7.jar:mahout-math-0.7.jar ReutersToSparseVectors.java
created JAR file with below command:
jar cvf ReutersToSparseVectors.jar ReutersToSparseVectors.class
When I write java -jar ReutersToSparseVectors.jar to run, give me below error:
Failed to load Main-Class manifest attribute from
ReutersToSparseVectors.jar
Do you can help me to solve this problem?
IF this example can run with hadoop, please me that how i can run this with hadoop.
instead of using -jar option, then it's better to to run:
java -cp mahout-core.jar:... mia.clustering.ch09.ReutersToSparseVectors
or you can use mvn exec:java command, as described in README for examples...
mvn exec:java -Dexec.mainClass="mia.clustering.ch09.ReutersToSparseVectors"
Or you can run this file directly from your IDE (assuming, that you correctly imported Maven project).
P.S. your command isn't working, because to run with -jar switch, the .jar file should have special entry in manifest that describes that class should be started by default...
P.P.S. It's better to use book's examples with Mahout 0.7, as they were tested for it. You can use it with version 0.7 if you need, by then you need to take source code from mahout-0.7 branch of repository with examples (link is above)

How to Execute Clojure File?

How can I run a clojure file/script, which uses clojure-contrib, from the command line? My (winodws) machine has clojure-1.2.1.jar and clojure-contrib-1.2.0.jar on the classpath. Note: I can start the REPL with: java clojure.mainand I can execute *.clj files that DO NOT use clojure-contrib with: java clojure.main file-name.clj
You need to add the clojure-contrib jar to the classpath. Since you are using windows, you add multiple classpaths by separating the entries with semicolons.
java -cp clojure-1.2.1.jar;clojure-contrib-1.2.0.jar clojure.main file-name.clj
The above code should enable you to run your file-name.clj script which depends on clojure-contrib.
This line will run a clojure script "hello-world.clj". It first adds the clojure jar to the class path first and then will execute the file.
java -cp clojure.jar clojure.main hello-world.clj
for those used to text editor + lots of shell work
lein run isn't bad
and lein projects can help you organize deps and other proj-specific

Setting the classpath

hi i have written one shell script which is performing 1 task.
java -jar abc.jar $* -adminid $j_username
before this command i want to set classpath(or want to refer) of all jars which are in particular lib folder, how to do that?
set CLASSPATH=pathtojars1;pathtojars2
before your java command.
Or:
java -classpath
One way to do it would be:
set CP=abc.jar:someother.jar
java -cp $CP your.main.Class $* -adminid $j_username
It is worth while to note that when using -jar you can't specify other JARs/resources on the classpath i.e. -cp switch is ignored hence you would have to choose between the two.
Create a standalone JAR which
incorporates other JARs/resources
Have different JAR files but instead
of using -jar specify the main
class when running the program

Resources