Chinese characters in gitignore - java

I am using git for bunch of my java projects. I want to ignore .classpath, bin, .gradle and bunch of other files and folders.
I cannot access this files / folders in eclipse to ignore them from eclipse. Hence I decided to edit the .gitignore file. The file contains random chinese characters.
I still went ahead and updated the .gitignore file with the required file list. However, when I ignore any other file from eclipse, the .gitignore is again appended with chinese characters.
Is this expected behavior? How do I add files like .classpath, bin and others to gitignore?

I fixed this issue. It was an encoding issue. The .gitignore file was created by someone else. I don't know what editor / platform was used to create the file.
I am using eclipse on windows. I had tried opening the file in eclipse editor / notepad / notepad++. All I could see is chinese characters. Even if I added a new file to .gitignore from eclipse (Rt Click --> Team --> Ignore), the file was appended with more chinese characters.
I changed the encoding of the file from "Default" to US-ASCII / Cp1252. I am seeing the expected data now. I can edit this file in notepad and adding new files from eclipse also gives expected results.
UPDATE:
To view .classpath, bin, build, .gradle and other such files and folders in eclipse package explorer, click on the small arrow in the top right of the package explorer. Select "Filters" from the drop-down menu. Select / deselect the filters.

AFAIK .gitignore opened in the simpliest notepad shouldn't have any "chinese characters", should be plain text. Maybe you have a different font set up in your notepad or something?
Here you can see some examples of how it should look How do I ignore files in a directory in Git?

Related

Visual Studio Code not automatically create bin folder, file .classpath and file .settings for java language

I have some problem in visual studio code :
Visual studio code for java not create folder bin, file .classpath, .project and .settings automatically.
Sreenshoot :
In explorer VSC
File app.java and app.class in the same folder (src), when I look tutorials in youtube, file .class should be in bin folder.
In settings.json there is file.exclude, when I change .classpath to the false or delete it. It always reset to the true again. But if I run my code. it works.
Screenshoot : settings.json file (user)
Can someone help? I've search in any forum but never found solution and make sure path in my environment is correct!
Windows 10, VSC 1.53.0, jdk 15 (latest)
Edited
I ask this question when I'm very new with Java, now I understand, some file like .classpath, .project and etc will show when I use build tools like gradle or maven. Maybe because tutorial on youtube use old vscode version and not explain more about this file, actually this is like dumb question. But maybe this can help someone that new in Java too
If your project is newly created in VS Code through the command Java: Create Java Project.... This command will create a new project without build tools. (No Maven and Gradle). In that case, the files such as .classpath, .project, etc... will be hidden in the workspace storage path, which is by design, since we want the user just focus on the code itself.
If you want to see the bin folder, there is a setting called java.project.outputPath, you can set a relative path to that setting, then the output folder will be explicitly show in your project. For example: "java.project.outputPath": "bin"
Note, the setting java.project.outputPath only takes effect in the workspace scope.
I'm not interested at the youtube tutorials, but the folder structure in vscode-java is indeed like what you see.
In integrated Terminal, there'll a series of execution scripts shown before the real output. The one ends of folder bin is also the current project's classpath. The .class files which is generated by being compiled are stored there.
Setting.json is stored under the folder .vscode. This is your workspace setting, which is generated by pressing Ctrl+, and choosing workspace.

Java files became encoded

So I'm not sure what the reason is/was, but now (only)two out of my five .java source file are loading in Eclipse as a single row of squares. I opened it in notepad and it showed the encoding (a lot of East Asian characters and I even saw a sun and stuff), but now it only shows squares in Eclipse, and nothing elsewhere.
Can somebody explain what may have happened and offer a solution?
Right Click on the file in Eclipse and select 'Replace With > Local History' Eclipse will show you a list of previous versions of the file (if it has any). You can replace the bad current version from those.
Take the time to set up a backup system. Also use a version control system like Git or SVN to keep good copies of your files.
Try Preferences -> Workspace -> Text file encoding and other UTF-8

ECLIPSE: How to export the smallest jar file

My project's jar file size is getting bigger and bigger as more stuff is added into it. I am wondering if someone has tips on how to generate a smaller jar file.
I export it as a Runnable JAR file and the library handling is Copy required libraries into a sub-folder next to the generated JAR.
In the Properties - Java Compiler - Classfile Generation, everything is unticked.
With these options, I was able to save approx 3MB of space. And I am hoping I can save more by removing the unneeded data.
My .jar file has a .java._trace files in it. How can I remove this from the jar file?
A .xtend and .class file is also there for each class. Since the .class file is just a conversion of the .xtend, I want to remove either one of these from the jar file. How can I achieve this?
I would appreciate any tips and tricks that can help me reduce the size of the jar file.
If you want to exclude the source code file from the generated JAR file of an Xtext based project (and I think any Eclipse plug-in as well), open the plug-in.xml file which is located in the projects root folder. Navigate to the tab "Build" and make sure that your source folders are not selected. Normally there are three source code folders "src", "src-gen" and "xtend-gen". Also the "doc" folder which contains generated java doc is not necessary.

Eclipse plugin for exporting svn diff to JAR

I'm looking for SVN plugin, which can export diff files between 2 revisions to runnable jar file.
So I will give it to another man, who just run it on test/production server, and jar automatically will update project with exported diff files.
It's easy to write command tool like I need, but I'm looking for Eclipse plugin.
If I'm reading this right my issue is similar to yours.
Back in Eclipse 3.2 (ish) in the synchronize perspective, you could select locally changed files, then do File > Export and choose JAR, and it would select the files for you. Now it doesn't.
If you want just the text diff, it's easy. Just use the create patch option.
If you want to create a jar containing the changed files - which I find useful for recording the changes for a chunk of work, or saving the alterations to a branch when I want to work on another, then its possible but unnecessarily laboured. (Works with Indigo)
Exporting changes in eclipse Synchronize view:
Select all of them in the synchronize view
Right Click and choose Show In > Project Explorer
In the Project Explorer that appears, all the files should be selected. Some may be collapsed in their parent package. Use the + to make sure they are all visible and selected.
right click in the Project Explorer and choose Export > Java > Jar File, or drag the files into an explorer window if you want them in a flat directory.
What you want is just not possible (at least, not using SVN / text diffs).
SVN/diff work with text files. The result with diff is a excerpt with only the lines changed in a file (in this class a .java source file). These files cannot even be compiled because they are not java code (even if the lines themselves are).
What you may do is use svn log to check which files have changed, retrieve the associated .class files and use them to patch the server. Do not know if there is any tool that makes that automatically, though (and it is complicated as often the .class files are not commited into subversion).

Can't open my Java project in NetBeans

I am working with JDA+NetBeans. Suddenly my project refuses to open. I get the error
Invalid byte 1 of 1-byte UTF-8 sequence.
How can I fix it?
I suggest to look for UTF-8 characters (such as umlauts etc.) and delete/replace them; you could also try to open the file with another editor, save it and try Netbeans again.
open your files in notepad++ choose
Format -> convert To UTF-8
If the project get not opened, one of the project configuration files in the nbproject folder are corrupt. You can do:
Create a new project and copy the sources to the new project (and all the other things you did in the old project)
Open the corrupt project thru the Favorites window. Have a look into the nbproject files, maybe save again the files when opened from the Favorites window.

Categories

Resources