cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Add jars to a executable JAR file_OTK Java

VladiSlav
17-Peridot

Add jars to a executable JAR file_OTK Java

Hello everyone!

Please tell me how to add dependencies (other jar files) to the project jar file.
For example, I want to use logging during development, but I can not start the application, since Creo throws an error that the class will not find.
I used the gradle build tool.

I pointed out the classpath in MANIFEST, added jar files inside my jar, but it still doesn't work.

My gradle code:

jar {
    //from {
    //	configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    //}
    manifest {
        attributes(
                "Implementation-Title": "Jar Making Example",
                'Implementation-Version': "1.0",
                "Main-Class": "ru.Test",
                "Class-Path": configurations.runtimeClasspath.files.collect { it.getName() }.join(' ')
        )
    }
    destinationDirectory = file("build\\tmp\\jar")
    archivesBaseName = 'app'
    //C:\Program Files\PTC\Creo 5.0.2.0\Common Files\text\java\otk.jar
}

My jar:

VladiSlav_0-1582382860389.png

My MANIFEST:

VladiSlav_1-1582382905193.png

My code:

public class Test {
   
    private static final Logger log = LogManager.getLogger(Test.class);
    public static void start() throws jxthrowable {
        Session session = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
        session.UIShowMessageDialog("Hello", null);
        log.error("Hello!");
    }
    
    public static void stop() throws jxthrowable {
        
    }
}

This code works without the log4j2 classes in Creo.
Logging also works in the IDE if the start () method is started from the main () method.

 

Thanks in advance!
Best Regards!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

you can add information about dependencies in the registry file called creotk.dat or protk.dat to field java_app_classpath.

 

For more info search CLASSPATH Variables and Registry File in documentation.

View solution in original post

2 REPLIES 2

Hi,

you can add information about dependencies in the registry file called creotk.dat or protk.dat to field java_app_classpath.

 

For more info search CLASSPATH Variables and Registry File in documentation.

Thanks for the answer!

Announcements