This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Why do we use rt.jar in a java project?
I am very confused to knowing about rt.jar file.
What is the role
of rt.jar file or use of rt.jar file
in java??
Thanks.
rt.jar contains all of the compiled class files for the base Java Runtime environment. You should not be messing with this jar file.
For MacOS it is called classes.jar and located under /System/Library/Frameworks/<java_version>/Classes . Same not messing with it rule applies there as well :).
http://javahowto.blogspot.com/2006/05/what-does-rtjar-stand-for-in.html
Your question is already answered here :
Why do we use rt.jar file in java project ?
Basically, rt.jar contains all of the
compiled class files for the base Java
Runtime ("rt") Environment. Normally,
javac should know the path to this
file
Also, a good link on what happens if we try to include our class file in rt.jar.
Related
This question already has answers here:
Is Maven ready for JDK9?
(6 answers)
Closed 5 years ago.
In Java 9, you can create a JAR file with
jar --create --file=mlib/com.greetings.jar --main-class=com.greetings.Main -C mods/com.greetings .
Which has the side effect of adding the MainClass attribute to the module-info.class file in the .jar file.
Do any of the plugins support this yet, or do I need to invoke the Java 9 'jar' command directly?
Is this the right forum to be asking these questions, or is there a better place?
Cheers, Eric
The 'module main class' is actually an attribute of the module-info.class file. It's called ModuleMainClass and set by the Java 9's jar command. The current version (3.0.2) of maven-jar-plugin only writes the file when you specify the manifest.mainClass
This question already has answers here:
How do I find the packages defined in a jar?
(5 answers)
Closed 8 years ago.
Is there any way to know the packages of a .jar file as I want to use "gtranslateapi-1.0" but not getting the package or class names in it.
I have also added it to my libraries in netbeans 8.0
You can see it here: https://code.google.com/p/java-google-translate-text-to-speech/downloads/list
please help, thanks in advance !!
jar is just a zip.so if you want to know what is packed into a jar file, you may unzip it (using either your favourite zip tool or jar itself e.g jar -t to list the contents). hint jar without args gives you a list of options
in netbeans you can easily see packages and classes .or you can rename .jar to .zip and open in compress program like winrar
in netbeans you can expand jar easily.add jar to libries and expand it .this is your jar file
This question already has answers here:
Updating .class file in jar
(11 answers)
Closed 9 years ago.
So, I have third party library, which is a .jar file. There are some classes in that jar. The problem is, there is one bug in one class in that .jar. I know it because I can decompile the jar file, to look at the java code, which is I am pretty sure, that class is the source of my program bug.
The idea is, I delete the class and replace it with my own class, but I dont know how.
There are multiple ways to do this:
Try to use winrar. You can open your jar in it, explore the directory containing the class file. You can delete and add class files.
If you don't want to use winrar then do like this:
Extract the jar using this command
jar -xvf yourjar.jar
It will explode the jar. Delete the old class file and add your updated class file
Recreate the jar using the following command
jar -cvf yourjar.jar directoryofexploderjar/
Extend class and rewrite method removing bug
Use JDEC to decompile and replace class ( http://jdec.sourceforge.net/ )
Write your own class in the same package as the original one, make sure your classes are before the 3-rd party jar on the java classpath. This way you will override the original version, class loader will load your class.
This question already has answers here:
Closed 12 years ago.
Possible Duplicates:
Where can I find a Java decompiler?
How do I “decompile” Java class files?
Any tool can decompile the class back to java source? Like the reflector in C#?
See How do I "decompile" Java class files?
About JAD: http://viralpatel.net/blogs/2009/01/decompile-class-file-java-decompiler-class-java-class.html
you can use javap command for that
javap classname
to get the full code i guess there are a lot of java decompilers available on net for free..
A Java class can be decompiled by using a decompiler which takes a .class files as input and gives its Java source code as output.
Refer these questions on stackoverflow for more details.
How do I “decompile” Java class files? (Using external tools)
How to Decompile Java (using javap command that is available with JDK)
Also See
What is the best software to decompile a java class file ?
Where can I find a Java decompiler?
Decompile compiled Java file with proprietary headers
This question already has answers here:
Including all the jars in a directory within the Java classpath
(25 answers)
Closed 4 years ago.
I have been using so many 3rd party libraries(jar files) that my CLASSPATH is completely messed up as i have to include the path for every single jar file that i use.
I've been wondering if there is a way to include all the jar files in a folder using wildcard(*) operator (like *.jar). But it seems to be not working. Is there any other way that can shorten the CLASSPATH that currently looks like an essay ;) on my PC?.
From: http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html
Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/* specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.
This should work in Java6, not sure about Java5
(If it seems it does not work as expected, try putting quotes. eg: "foo/*")
This works on Windows:
java -cp "lib/*" %MAINCLASS%
where %MAINCLASS% of course is the class containing your main method.
Alternatively:
java -cp "lib/*" -jar %MAINJAR%
where %MAINJAR% is the jar file to launch via its internal manifest.
Basename wild cards were introduced in Java 6; i.e. "foo/*" means all ".jar" files in the "foo" directory.
In earlier versions of Java that do not support wildcard classpaths, I have resorted to using a shell wrapper script to assemble a Classpath by 'globbing' a pattern and mangling the results to insert ':' characters at the appropriate points. This would be hard to do in a BAT file ...
If you mean that you have an environment variable named CLASSPATH, I'd say that's your mistake. I don't have such a thing on any machine with which I develop Java. CLASSPATH is so tied to a particular project that it's impossible to have a single, correct CLASSPATH that works for all.
I set CLASSPATH for each project using either an IDE or Ant. I do a lot of web development, so each WAR and EAR uses their own CLASSPATH.
It's ignored by IDEs and app servers. Why do you have it? I'd recommend deleting it.