Jigsaw cannot create a modular JAR with the jar tool - java-platform-module-system

I am using the build 9-ea+129-jigsaw-nightly-h5332-20160730
I have a very simple module with a Main class and a module-info.java
I compile the module using javac --module-source-path and everything is ok. The class files are being generated for both module-info.class and Main.class
javac -d modules --module-source-path src $(find . -name "*.java")
When I try to create the modular JAR file with the jar tool, I get the following error message:
module-info.class found in a versioned directory without module-info.class in the root
My module-info.class is there in the root directory.
I run:
$ jar --create --file mlib/ModuleFirst#1.0.jar --module-version 1.0 --main-class com.firstmodule.Main -c modules/com.firstmodule
Can you tell me why do I get this error and what I did wrong?
Thank you
Regards

I have the same problem
You should change a lot your command
$ jar --create --file mlib/ModuleFirst#1.0.jar --module-version 1.0 --main-class com.firstmodule.Main -C modules/com.firstmodule .
You must use the capital C and put the dot at the end of line

Related

Makefile "No such file or directory" when command is in PATH

I'm trying to write a Makefile in such a way that all of the steps in my recipe can call scripts a list of directories. As an example, I have node commands that are in a node_modules/.bin directory, but there could just as well be Python commands from a Python virtual environment as well, etc.
I have node installed, as well as TypeScript installed via npm in my /node_modules. Given my directory /tmp/test123, I wrote the following Makefile at /tmp/test123/Makefile as an example:
PATH = /tmp/test123/node_modules/.bin:$(PATH)
.PHONY: compile
compile:
env | grep "PATH"
tsc --help
However, if I try to run it, it outputs:
$ make compile
env | grep "PATH"
PATH=/tmp/test123/node_modules/.bin:... # the rest of my PATH
tsc --help
make: tsc: No such file or directory
make: *** [compile] Error 1
But if I change the last line to cd . && tsc --help, then compile runs successfully.
Why is make unable to find the tsc command in the PATH? Why do I need to run cd . && in front of it? Is there any better workaround than writing cd . && in front of all of my recipe steps?

Creating Fat Jars: What is the mods folder?

I'm just on:
https://openjfx.io/openjfx-docs/#modular
trying to create a jar I can run on other systems (that do not have the javafx libraries as would happen with a non-developer layman user) and they've told me to use this:
dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX% -d mods/hellofx #sources.txt & del sources.txt
What is mods/
Where is that supposed to be? Are they talking about out/ ?
The doc you have linked refers to this sample.
If you clone the sample, and follow instructions on how to compile and run the project, the first command can be divided in three parts:
dir /s /b src\*.java > sources.txt & \
javac --module-path %PATH_TO_FX% -d mods/hellofx #sources.txt & \
del sources.txt
The first part just gets all the Java files in the src path and adds that to sources.txt file:
C:\path\to\hellofx\src\module-info.java
C:\path\to\hellofx\src\hellofx\HelloFX.java
The second part calls the javac command (see reference) to compile the content of sources.txt, adding the required --module-path option to include the JavaFX modules, and also adding the output or destination -d option:
-d directory
Sets the destination directory for class files. If a class is part of a package, then javac puts the class file in a subdirectory that reflects the package name and creates directories as needed.
This means that we are going to compile hellofx.HelloFX.java into the directory mods/hellofx, resulting in:
C:\path\to\hellofx\mods\hellofx\module-info.class
C:\path\to\hellofx\mods\hellofx\hellofx\HelloFX.class
The third step will just remove the sources.txt file.
And now you can run your module:
java --module-path "%PATH_TO_FX%;mods" -m hellofx/hellofx.HelloFX
You can specify any directory for the output, of course, so you can change it to out or build for instance, but then make sure you modify it accordingly in the rest of the instructions.

How to compile java file from windchill shell

I am trying to compile a simple Hello World from windchill shell using command javac com.A.B.Test.
But it is displaying could not find main class error.
I think your problem is Java and not Windchill related.
Let's say your Java source file is stored in the following location:
/src/com/A/B/Test.java
To compile that file in shell (Linux for example):
cd /src
javac com/A/B/Test.java
To run that file (if it contains a main method):
java -cp /src com.A.B.Test
Try using the below command from the windchill Shell.
Hope you are following the default file structure provided by the Vendor i'm providing the same below otherwise just edit the path mentioned in the below command.
javac -d codebase -cp %CLASSPATH%;%WT_HOME%\srclib\tool\Annotations.jar src*.java
First Go to Windchill Shell then navigate to the folder where java file is present. At that location type javac Test.java and press enter.
Put the code into WT_HOME/src/com/package, than run from WT_HOME:
ant -f bin/tools.xml class -Dclass.includes=com/..path-to-package/*

Getting started with JavaCC

I am new to JavaCC and cannot figure out how to get it running. I am using Mac OS X and I installed javacc-6.0.zip and unzipped it. I am unable to make the javacc script accessible from my path as on typing javacc on the terminal I get the following message:
-bash: javacc: command not found
How do I make the javacc script accessible from my path?
My unzipped folder javacc-6.0 is in the following directory: /Users/Rishabh/Desktop/javacc
So I do the following on the terminal:
PATH=$PATH\:/Users/Rishabh/Desktop/javacc/javacc-6.0/
Typing javacc next gives me the same message.
The version of JavaCC 6.0 that I downloaded today (2013.07.22) did not have a complete bin directory. It was missing all the script files! Hopefully this will be remedied soon.
For OS X and other unix/linux variants, the missing script file is called javacc, should be executable, and should contain the following:
#!/bin/sh
JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;;
esac
java -classpath "$JAR" javacc "$#"
Add the bin directory to your PATH (omitting the backslash -- as pointed out by Ahmed Masud) and all should be ticketty boo. If your OS comes from Redmond or you want to run jjtree or jjdoc, just download javacc-5.0 and copy the script files (NOT the lib directory!!!!) from the 5.0 bin directory to the 6.0 bin directory.
Update (2020): Since version 6 is now harder to find, I have put a copy at www.engr.mun.ca/~theo/JavaCC/javacc-6.1.0.zip
In Windows, I also had no javacc and have to use
java -cp bin\lib\javacc.jar javacc
instead. This is very frustrating because all docs propose to use javacc, which we miss. Yet, I see that javacc was defined in the old javacc 5.0. I see javacc.bat there
java -classpath "%~dp0lib\javacc.jar;%~dp0lib\javacc.jar;%~f0\..\lib\javacc.jar" javacc %1 %2 %3 %4 %5 %6 %7 %8 %9
more javacc:
#!/bin/sh JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;; esac
java -classpath "$JAR" javacc "$#"
more jjtree:
#!/bin/sh JAR="`dirname $0`/lib/javacc.jar"
case "`uname`" in
CYGWIN*) JAR="`cygpath --windows -- "$JAR"`" ;; esac
java -classpath "$JAR" jjtree "$#"
Create these scripts in the bin folder of your javacc-6.0/bin.
make a chmod :
chmod 755 javacc
chmod 755 jjtree
On Mac OS X & Linux I just use a single script and two symbolic links:
echo 'java -cp /path/to/javacc.jar $(basename $0) "$#"' > javacc
chmod 755 javacc
ln -s javacc jjtree
ln -s javacc jjdoc
The first two lines create the script and make it executable.
The second two lines reuse the javacc script for jjtree and jjdoc, since it all comes from the same JAR.
You need to first unzip the package, and add location where your javacc is located in your
PATH environment variable.
like:
set path=%path%;<location_of_your_javacc>;
Check if you have javacc and jjtree in the bin/ directory of your javacc-6.0.zip. When you get javacc6.0 from https://javacc.java.net/, this bin directory is empty.
javacc & jjtree are scripts.
Actually i'm using Java 5.0 and i'm modified my .profile file to add (I put javacc in my Applications folder):
export
PATH=/opt/local/bin:/opt/local/sbin:/Applications/javacc-5.0/bin/:$PATH
It's working perfectly.

error: package javax.servlet does not exist/ directory not found

tomcat
-webapps
-Servlet
-WEB-INF
-lib
-classes
-cc
-openhome
-HelloServlet.java
in cmd ,
C:\tomcat\webapps\Servlet>javac -classpath .;c:\tomcat\lib\servlet-api.jar -d ..\classes\cc\openhome\HelloServlet.java
but message says directory not found
and I compile the HelloServlet.java , it shows package javax.servlet does not exist
I tried each method found from here, is anyone know what it happens? thank you
-d is the switch for changing output directory and not for defining a java source file and it expects a directory, not a file.
Also that class folder is usually for the compiled classes and not for the sources.
Try this:
javac -classpath .;c:\tomcat\lib\servlet-api.jar -d .\WEB-INF\classes .\WEB-INF\classes\cc\openhome\HelloServlet.java

Resources