• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

.java to .jar file

Joined
Dec 2, 2009
Messages
3,352 (0.59/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Hi guys!
I have a problem i think i dont know how to do this little thing
I have searched around the web, but i cant find anyone to explain it how to
and where to put this code down here in order for the compilator to convert it
from .java to a .jar file so the program or games i do in neatbeans can be executed in
my mobile phone!
Anyone can help??? The code is this one:
jar cf jar-file input-file(s)
 
well you'd put in in your command prompt, from wherever it can execute the java compiler.

if installed correctly, that should be anywhere. but you may have to navigate to the java install directory to call the executable.

i have no idea about java specifically, so i can't help much more than that i'm afraid.

you might want to mention windows or linux, as that will matter. i assume windows?
 
I have already posted windows in my system specs
 
Netbeans is the same on all OSs: Right-click on your project and choose "clean & build". The Jar executable will be made and put in the "dist" sub folder of your project.
 
I know the manual, i got the code from there
I just dont know where to put the code in the program i made
and what to put in :S?
 
if you know the manual then you know you dont put the code in the program, you convert all of your java class files into a jar file using their compiler.
 
As a side note to Easy Rhinos comment, you can only jar .class files, meaning that you need to compile all the .java files and them jar the .class files resulting from the compilation. Example:
Code:
javac Test.java
jar cf Teste.jar Test.class
 
Ok, but where to put the code?
I mean in a new class? In the middle of a class?
And inside are so many classes, which means with your code man, i need to put all in???
Or should i create the code again and again?
 
I know the manual, i got the code from there
I just dont know where to put the code in the program i made
and what to put in :S?

Code goes on a command line prompt as already mentioned...

but anyway since you are using Netbeans, it will sort all this for you as I already said :)

"Clean & build" project = jar file
 
you can either use the command line or whatever program you may have used to write the program.
 
Ok, but where to put the code?
I mean in a new class? In the middle of a class?
And inside are so many classes, which means with your code man, i need to put all in???
Or should i create the code again and again?

Yes, you need to compile every single file, and moreover, if one files has dependencies that cannot be solved automatically (the class is not in java.lang.path) you have to include the path to every unresolved class at the compilation process command line.
If I were you, for a big standalone application I would follow robn advice and use NetBeans to manage all the files in a projects, and let NetBeans/Ant figure out how to properly compile and build the jar (if you do use NetBeans the resulting jar file will be inside the dist folder inside the project folder).
 
Back
Top