how do I create an archive "classes.jar" which should contain 2 files ".class" (named as MyFirstClass.class and MySecondClass.class) using file I created "manifest.mf".
This must be done using the program javac, program jar and cmd.
2 files .class I already got using javac program.
This is all located in the folder C:\Task7
MyFirstClass.class file located in the folder C:\Task7\myPackage (because it is in the package "myPackage")
MySecondClass.class file located in the folder C:\Task7\myPackage\myfirstpackage (because it is in the packages myPackage and myfirstpackage)
myManifest.mf file located in the folder C:\Task7
My attempts to:
1) C:\Program Files\Java\jdk1.7.0_51\bin>jar cvfm classes.jar C:\Task7 manifest -C C:\Task7 myPackage.MyFirstClass.class myPackage.myfirstpackage.MySecondClass.class
cmd answer:
java.io.FileNotFoundException: C:\Task7 (Mbp4p3m r •meCesix)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at sun.tools.jar.Main.run(Main.java:171)
at sun.tools.jar.Main.main(Main.java:1177)
2) C:\Program Files\Java\jdk1.7.0_51\bin>jar cvfm classes.jar C:\Task7 manifest C:\Task7\myPackage\MyFirstClass.class C:\Task7\myPackage\myfirstpackage\MySecondClass.class
cmd answer:
java.io.FileNotFoundException: C:\Task7 (Mbp4p3m r omeCesix)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at sun.tools.jar.Main.run(Main.java:171)
at sun.tools.jar.Main.main(Main.java:1177)
3) C:\Program Files\Java\jdk1.7.0_51\bin>jar cvfm classes.jar C:\Task7 manifest C:\Task7\myPackage MyFirstClass.class C:\Task7\myPackage\myfirstpackage MySecondClass.class
cmd answer:
java.io.FileNotFoundException: C:\Task7 (Cbpgrosm r omeCegx)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at sun.tools.jar.Main.run(Main.java:171)
at sun.tools.jar.Main.main(Main.java:1177)
What am I doing wrong?
Keep all the file in a folder and Go to that location and use the following command-
jar -cvf abc.jar abc
if your folder name is abc.
If you run jar out of dir your class hierarchy is located, you shoud use -C option before the list of files. In your case it should be: -C C:\Task7
Related
I got the following error showing that it can not find i4jlauncher.config. How can I let it find the file? Is there an option or environment variable that I should specify?
$ pwd
/Applications/thinkorswim/thinkorswim.app
$ java -cp '/Applications/thinkorswim/.install4j/i4jruntime.jar:/Applications/thinkorswim/launcher-first.jar:/Applications/thinkorswim/launcher.jar' com.install4j.runtime.launcher.MacLauncher
error2: java.io.FileNotFoundException: null/Contents/Resources/i4jlauncher.config (No such file or directory)
java.base/java.io.FileInputStream.open0(Native Method)
java.base/java.io.FileInputStream.open(FileInputStream.java:211)
java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
java.base/java.io.FileInputStream.<init>(FileInputStream.java:108)
com.install4j.runtime.launcher.MacLauncher.readProperties(MacLauncher.java:64)
com.install4j.runtime.launcher.MacLauncher.main(MacLauncher.java:29)
$ ls Contents/Resources/i4jlauncher.config
Contents/Resources/i4jlauncher.config
You have to set the working directory to /Applications/thinkorswim/.install4j or pass -Dinstall4j.runtimeDir=<path to .install4j directory on the command line.
I have a spring boot app which is giving the below error on creating Persistence EntityManager factory.
Persistence.createEntityManagerFactory
The war file is available under
/opt/test/app/app.war
and WEB-INF/classes also present in this war file.
But classloader is failing with the below error.
Is there any permission missing?
oggerName="org.hibernate.orm.url" threadName="main" txnId="" HHH10000002: File or directory named by URL [file:/opt/test/app/app.war!/WEB-INF/classes] could not be found. URL will be ignored
java.io.FileNotFoundException: /opt/test/app/app.war!/WEB-INF/classes (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.resolveJarFileReference(JarFileBasedArchiveDescriptor.java:165)
at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:51)
at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:47)
at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:75)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:199)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
Docker file reference,
FROM alpine/jdk1.8:latest
RUN mkdir -p /opt/test/app
COPY app.war /opt/test/app/app.war
CMD java -jar /opt/test/app/app.war
In the pom.xml, change the packaging to jar
C:\Users\sunka\Desktop\CS DEPT\fall 2k16\information structures>jar
-xvf week2.zip
java.io.FileNotFoundException: week2.zip (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at sun.tools.jar.Main.run(Main.java:307)
at sun.tools.jar.Main.main(Main.java:1288)
When I am trying to unzip using jar -xvf, I am getting file not found exception. I used the same command in my office, it was working. I made sure that zip file and jar file are present in the directory.
Check if you in same directory where you have zip file placed.
Because if JAVA path is set properly and your are giving right zip file name with correct path it works fine.
I'm trying to create a jar file for one of my files (Worker.java). The file is in the beatDB package in the src/ folder.
To create the jar I ran jar cfm InitializeInstanceWorker.jar Manifest.txt -C src/ . and my Manifest.txt contains: Main-Class: Main-Class: beatDB.Worker \n with a new line at the end.
When I call java beatDB/Worker the file runs, but then when I try to run the jar file, java.lang.ClassDefNotFoundException:
Exception in thread "main" java.lang.NoClassDefFoundError: com/amazonaws/auth/AWSCredentialsProvider
Caused by: java.lang.ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I have aws-java-sdk-1.7.7.jar in my lib folder, which is on the classpath, which I set in my .bash_profile file.
Does anyone know why running the java file directly works, but the jar file does not run?
The ways that you can run your jar/main class are:
java -cp InitializeInstanceWorker.jar;lib\aws-java-sdk-1.7.7.jar beatDB.Worker
Or
java -cp lib\aws-java-sdk-1.7.7.jar beatDB.Worker -jar InitializeInstanceWorker.jar`
Or, if you add the attribute Class-Path: lib/ in your jar, you will be able to run it by:
java -jar InitializeInstanceWorker.jar
Hope it helps!
I am trying to write a batch file that writes the classes-dex2jar.jar to some other folder.
I tried the following:
d2j-dex2jar %arg1% -o %arg2%
Here, arg1 is the path to classes.dex and arg2 is the folder where I wish to store the generated classes-dex2jar.jar file. (E:\new\)
Now, I am getting FileNotFoundException for the second argument. It says
java.io.FileNotFoundException: E:\new" (The filename, directory name,
or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.commons.io.FileUtils.openOutputStream(FileUtils.java:77)
at com.googlecode.dex2jar.v3.Dex2jar.to(Dex2jar.java:250)
at com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine(Dex2jarCmd.java
:110)
at com.googlecode.dex2jar.tools.BaseCmd.doMain(BaseCmd.java:174)
at com.googlecode.dex2jar.tools.Dex2jarCmd.main(Dex2jarCmd.java:34)
Please tell me what am I doing wrong?
Instead of passing the folder as an argument, pass it the jar filename.
d2j-dex2jar classes.dex -o "E:\new\classes.jar"
Also make sure E:\new directory exists. Dex2jar does not create a new directory. Create a directory and then pass d2j-dex2jar the full path to the directory plus the jar file name you want.
java.io.FileOutputStream.open - looks like you'are trying to open directory with FileOutputStream , which should be not possible.