How to compile java file from windchill shell - ptc-windchill

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/*

Related

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.

Is it possible to write python code in spec file which is generated by pyinstaller?

There are some commands that has to be executed with spec file. Is there any possibility to include commands in spec file.
I have to execute the following statement:
rm -rf build dist
I need to include in spec file.
When I run
pyinstaller --clean abc.spec
it has to delete build folder and dist folder
From the pyinstaller documentation:
The spec file tells PyInstaller how to process your script. It encodes the script names and most of the options you give to the pyinstaller command. The spec file is actually executable Python code. PyInstaller builds the app by executing the contents of the spec file.
So, you can include python code in the spec file to perform the operations you want. But it will need to be python code, not terminal commands as you have.

Jigsaw cannot create a modular JAR with the jar tool

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

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

Class-path in manifest not read when running jar in Unix

I have a client application that needs to run on Unix. It works fine in Windows but i get a NoClassDefFound exception in unix. Here's my manifest file:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 2.3 (IBM Corporation)
Main-Class: com.main.Client
Class-Path: lib/commons-lang-2.3.jar lib/commons-io-1.3.2.jar lib/comm
ons-logging-api-1.1.jar lib/log4j-1.2.12.jar
And the Client.jar structure:
com
com/main
lib
meta-inf
To run it, i use the command below:
$JAVA_HOME/jre/bin/java -jar Client.jar
It works fine in windows. Somehow i think that its not reading the manifest right. Help please! Thanks!
Maybe because your meta-inf folder is in lower-case?
One way is to make sure you have defined your CLASSPATH variable for the user that is running the program.
$ echo $CLASSPATH
if there is nothing shown from the above, then export it
$ export CLASSPATH="/lib/commons-lang-2.3.jar:/your/other/paths"

Resources