Absolute Beginner

130 views
Skip to first unread message

Robert Calfee

unread,
Oct 10, 2016, 6:55:31 PM10/10/16
to quasar-pulsar-user
I have no Maven, no Gradle, never seen them before today when I read about Quasar's fibers and started trying to put together a project.

I'm familiar with Netbeans and wanted to set this up as a project there and experiment with fibers, but really I'm at a loss as to what needs to be done and how.

I'm running a windows system btw.

I know at the far end, I'll be marking methods with throws SuspendExecution but what are the steps between downloading the sources from git and typing up my test code?

Robert Calfee

unread,
Oct 11, 2016, 4:19:51 PM10/11/16
to quasar-pulsar-user
All right, I did get the project to build. Though I could not get Maven to work right for me to gather the dependent jar files, I was able to locate and install them by hand.

Now I have a quasar-core.jar, but I cannot get it to instrument the test program for me

--- exec-maven-plugin:1.2.1:exec (default-cli) @ quasar ---
QUASAR WARNING: Quasar Java Agent isn't running. If you're using another instrumentation method you can ignore this message; otherwise, please refer to the Getting Started section in the Quasar documentation.
Exception in thread "main" java.lang.IllegalArgumentException: Fiber class com.paralleluniverse.quasar.FiberSample$1 has not been instrumented.
    at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:186)
    at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:225)
    at co.paralleluniverse.fibers.Fiber.<init>(Fiber.java:515)
    at com.paralleluniverse.quasar.FiberSample$1.<init>(FiberSample.java:20)
    at com.paralleluniverse.quasar.FiberSample.main(FiberSample.java:20)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.306s
Finished at: Tue Oct 11 13:13:56 PDT 2016
Final Memory: 7M/184M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project quasar: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

I know I'm missing something, just not sure what.
pom.xml

victo...@gmail.com

unread,
Oct 12, 2016, 5:34:38 AM10/12/16
to quasar-pulsar-user
you need to configure the exec plugin to setup the quasar agent.

The best is to take a look at the pom demo for quasar, just generate it by following the instructions there: https://github.com/puniverse/quasar-mvn-archetype

Robert Calfee

unread,
Oct 12, 2016, 4:19:55 PM10/12/16
to quasar-pulsar-user
I have used the mvn-archetype and achieved some success: the program will build and run in netbeans (yay!) Thanks for that.

I used the AOT option to preinstrument the classes and was experimenting with preparing a .jar file that would execute.

I collected the dependencies for quasar in a directory ./libs and have the jar file in .

 this runs:
java -cp ./libs/*;quasar-aot-1.0-SNAPSHOT.jar testgrp.QuasarIncreasingEchoApp

This does not:
java -jar quasar-aot-1.0-SNAPSHOT.jar
it gives a  java.lang.NoClassDefFoundError: co/paralleluniverse/strands/SuspendableCallable

The manifest file is attached


MANIFEST.MF

pron

unread,
Oct 13, 2016, 3:58:12 AM10/13/16
to quasar-pulsar-user

This is not how you add a classpath to a JAR file. See this. You may want to look at Capsule for single-file binary deployments (there's a Maven plugin that makes the build very easy).

I would also recommend that, as a beginner, you first use the Java agent rather than AOT instrumentation, especially if you're not yet comfortable with your build tool. In general, the agent is always preferable (beginner or not); use AOT only if you have a very good reason to.

Ron
Message has been deleted

Satej S

unread,
Oct 17, 2016, 3:17:17 AM10/17/16
to quasar-pulsar-user
Adding to what Ron mentioned, if you're using Intelli-J, it's very easy to provide a java agent. Follow the steps below assuming you have already downloaded the jar file.
  1. Hit Alt-Ctrl/Command(Mac)-R and hit Edit Configuration ,
  2. Add the following:  -javaagent filepathtojar.jar in the VM arguments. 
 Here is a sample of the file path : -javaagent:/Users/yourusername/Foldername/subfolder/quasar-core-0.7.2.jar 

Robert Calfee

unread,
Oct 18, 2016, 12:41:53 AM10/18/16
to quasar-pulsar-user
Hi.

I had seen that link about class paths and jar files. I have tried just about everything I could to get the jar file to recognize the needed dependent .jars. Nothing would work.

I guess I don't understand what your mean when you say "This is not how you add a classpath to a JAR file." I included them all in the manifest individually, but it was too long, so I gathered them into a directory, as I said, that did not work either.

And in any case I do not see any way to launch the jar and the agent. Using AOT, and then one-jar worked to create a jar file that I could launch with
 java -jar quasar-aot-1.0-SNAPSHOT.jar

So my question would be: why would I not use AOT?

pron

unread,
Oct 18, 2016, 9:31:47 AM10/18/16
to quasar-pulsar-user


On Tuesday, October 18, 2016 at 7:41:53 AM UTC+3, Robert Calfee wrote:
I guess I don't understand what your mean when you say "This is not how you add a classpath to a JAR file." I included them all in the manifest individually, but it was too long, so I gathered them into a directory, as I said, that did not work either.

The most common way is to list them all on the command line in a script. Anyway, this is what a build tool (like Maven or Gradle) is for. It will create the script or the manifest for you, even if it's long.
 

And in any case I do not see any way to launch the jar and the agent. Using AOT, and then one-jar worked to create a jar file that I could launch with
 java -jar quasar-aot-1.0-SNAPSHOT.jar

You need something to setup your command line anyway. Often people use shell scripts generated by their build tools. I recommend Capsule, as it packages everything, including all dependencies, into a single executable JAR, which automatically sets up the command line, including the agent, when you run `java -jar myapp.jar`
 


So my question would be: why would I not use AOT?

Because it makes the build more complicated and you're still a beginner with the build tool. It may also let problems in the build process introduce subtle bugs. Anyway, since you are a beginner, you should definitely use the agent first. You may switch to AOT later if you like, although I see no good reason to in most cases. But first of all, you should get comfortable with real-world projects, which require dependency management, build tools and the like. Those tools are an integral part of modern, real-world software development, not only in Java, but in all languages you'll encounter.

Ron

Fabio Tudone

unread,
Oct 24, 2016, 1:36:09 PM10/24/16
to quasar-pulsar-user
I'll only add that AOT works at build time so clearly it can't instrument anything you don't build yourself, like (usually) 3rd-party libraries, so typically integration modules will need runtime (agent or classloader) instrumentation (unless of course you repackage dependencies yourself after AOT-instrumenting them but this is usually not very practical).

-- Fabio
Reply all
Reply to author
Forward
0 new messages