I have a java project that I created in the NetBeans IDE version 8.0.1. The project contains a gui which I created with the NetBeans Gui builder, two external API's, and of course some of my personal code. I would like to make this project available to the public, but I don't want someone to be able to just take my project and upload it into an IDE and see all of my work. How do I need to go about making my project codew private and/or inaccessible. All the user should be able to do is run the jar file and use all the functionality of the program. Thanks for the help!
By default JAR files are build without sources if you use NetBeans (with its Ant-based build system), Maven or Gradle. It will only contain *.class files and resources (text, XML, images and other files).
Of course it is possible to decompile *.class files from your JAR. If you want to go an extra step you can obfuscate generate code to make it harder to understand what's going on there.
Related
Is there a way to make changes in jar which doesnot have source code in it and rebuild it with this change as a jar in eclipse.
You can look into using Java decompilers; in order to turn the .class files within the JAR archive back into .java source code. The process and some tools for that are outlined here.
But: understand that *decompiling" can be a tough business! Plus: there is always the question if the licence terms of the library you are using allows you to do that. Being able to do something isn't the same as being allowed to do that!
Finally: keep in mind that a JAR is just a deployment artifact. A lot of libraries are open source, and you can most often download that source and build the corresponding JARs completely on your own.
I am trying to decompile a java project(.jar) file and I am able to get .java files from it. Now how can I compile it back? I am able to add the .java files to Netbeans just as a single file.But how can I add it as a project add compile it? The project is a JavaFX project. So please help me on this.
There are many ways to achieve this, but I don't think you will be able to import the project inside the jar just out of the box ( in this case, out-of-the-jar ) like that.
We can use the most basic technique ( a bit dirty I admit ) but it works.
Extract the contents of the jar in a directory and decompile it like you done it before
Next, make an empty project inside netbeans ( with no src directory or anything )
Copy the contents of your decompiled project into this netbeans folder. You should now see a skeleton structure of some files. Note The poject is inisde netbeans but it is not a java project yet.
Edit the classpath of the netbeans project and add java library to make it into a Java netbeans project.
The other technique that I use sometimes is that I make all the project files required by the IDE (Eclipse in my case) manually and then tell eclipse to import the project. When eclipse finds all the required files ( .project, .classpath and all ), it imports into the IDE just fine
Create a JavaFX project in your IDE.
Decompile the jar to get the java files. The files will be places in
different folders and sub folders based on the packaging.
Put the folders as packages in the project created in step 1 above.
Clean and compile the project in your IDE.
P.S: Make sure you respect the license agreements if you are planning the use the decompiled and recompiled classes in your project.
I created a simple project using WindowBuilder in Eclipse and my goal is to send it by email. I don't know what kind of computer the person is using, so I exported my project into a 'Runnable JAR File' and checked the option 'Extract required libraries into generated JAR'.
The problem is that the generated JAR file is 20MB in size!!! The project has only one simple window - nothing complicated or fancy.
I found that some people use ProGuard to include only what is really needed.
I would like to know if there is a way to optimize it 'manually'? Are there libraries that are automatically included when creating a WindowBuilder project, and how may I determine which libraries I can remove?
Thank you.
I've had the same Problem using WindowBuilder. My solution was to look for the imports in my .java file, e.g.: import org.eclipse.swt.SWT;
In the Project Explorer in Eclipse you can see that there are much more imports than needed. Those 'Build Paths' can be removed carefully.
Simply rightclick on a .jar import like "com.ibm.icu_52.1.0.v201404241930.jar" and click on "Build Path" and "Remove from Build Path". Unfortunately, you can't remove or delete the packages inside the .jars.
But using this method, I managed to reduce the size from 20.7MB to 3.87MB. It's something...
Like fge said, send the source. Or upload the .jar to dropbox if you require you partner to access all of the files in the .jar.
If you don't like dropbox, find some other cloud storage solutions through a google search. Github or Bitbucket could also be an alternative to dropbox.
Cheers.
Use the Eclipse plugin FatJar. FatJar shows you which libraries are getting imported and allows you to specify which .jars, libraries, etc., that you want built into your JAR.
FatJar
Your jarfile is too big due of the project template. Create a sample java project, then use windowdbuilder components. Do not create a project Swing Template, by this way eclipse is gonna import all eclipse gui toolkits.
Tried it out with my way, my application's length equals to 3Ko against 24MO with the template project
Im writing a server based application and i would like eclipse to be able to interact with it.
I was wondering if eclipse PDE can handle using an external jar to interact with RabbitMQ. Also would i have access to the editor i.e. could the server respond and then update the code on the users end inside the editor pane?
Also if anyone knows any good resources for eclipse plug-in development that would be great as the only books i can find on amazon are a few years old
Thanks,
Ben
You can include any JAR in your plugin and write code that uses it.
Copy the JAR into your plugin project (usually they're placed into a lib folder in the project).
Open your plugin's manifest or plugin.xml file and go to the Runtime tab.
In the Classpath section, use the Add... button to add the JAR.
Go to the Build tab and make sure the JAR is selected at least for the Binary Build.
Save.
Now you should be able to write code that uses the JAR and when you build your plugin it will be packaged in your plugin.
If you find that you'll be writing multiple plugins that go together and all use the same JAR(s), there's a better way to package it, but I'll leave those details out for now.
Alright, so for a homework assignment I had to make a simple application with java swing. I used the netbeans GUI builder to do it and it works fine. However, when I zip up the entire folder (Documents\NetBeansProjects\Lesson 7) my professor complains that he doesn't have all the files. What other files could there be? I'm zipping up the whole folder that includes build, nbproject, src, test, build.xml, and manifest.mf. Is there anything else I need to zip up, or is my professor doing something wrong?
Netbeans GUI Designer uses the:
Swing Application Framework (JSR-296)
Netbeans keeps those separate as libraries (see the Libraries Item in the Projects view of Netbeans). Netbeans Libraries can be viewed under:
Tools --> Libraries
In order to run your application, you will need to supply the 'appframework' and 'swing-worker' jar files so that they can be added to the classpath in order to run the application.