This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using ant to jar up an application and it is going ok. However I have two minor problems which I think are class path related. First how do I run a class from the jar I create, I want to run java from inside the directory that contains the jar. Secondly how can I have a build.xml for ant in each projects src dir and run ant from inside the src dir.
"....bigmouth strikes again, and I've got no right to take my place with the human race...."<p>SCJP 1.4
Still have problem running the single class jar:- C:\j2sdk1.4.2_01\bin>java -jar C:\javaprojects\ant_test\dist\project.jar wibble Failed to load Main-Class manifest attribute from C:\javaprojects\ant_test\dist\project.jar the jar was created with ant, has I class wibble with a main method
Joined: Dec 10, 2002
followed the example on creating a jar given by Dirk, but double clicking the jar gives error message "exception in main thread" (I think, the console window flashes by )
Any answers anyone? I can create jars it seems, but can't run them via double click of the command prompt.
Joined: Dec 10, 2001
Can you run them from a command prompt? If so, then it's likely a case of the JAR file type not being properly registered with your OS in order to be able to run them by double-clicking on them. If you can run them from a command prompt, and you'd like some help with adjusting your OS settings to work with double-clicks, just post a note. Note that the syntax to run execute a JAR from a command prompt is java -jar MyJar.jar
Joined: Dec 10, 2002
my jar is under C: C:\>C:\j2sdk1.4.2_01\bin\java -jar MyFoo.jar Exception in thread "main" java.util.zip.ZipException: The system cannot f e file specified at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:112) at java.util.jar.JarFile.<init>(JarFile.java:127) at java.util.jar.JarFile.<init>(JarFile.java:65) seems I have had every error message imaginable. I have look into the jar and it seems to be ok - a single class with no package dec.
>Still can't get this working. > That doesn't tell us much. What did you try? What errors do you get (if any)? Give us some code, some command lines, some build scripts, etc., etc. We're not mind readers brian