Jump to content

I need a big favor with project for college

the second one which i mentioned many times. It is an OS sphere in other words something like Linux terminal Windows CMD which allows user to make folders, delete them move around them give privilages to them and so on. 

So a CLI shell then?

 

What you basically need to do is build an interpreter for the CLI. Here's a good guide for a simple interpreter I found : http://www.ruslanspivak.com/lsbasi-part1/ . The article doesn't cover what you are trying to achieve , but rather something which has the same principles as its base.

 

What you are trying to do is really easy to do in Python , where you can make your own CLI derived from cmd class built into the programming language. Here's more documentation : https://docs.python.org/2/library/cmd.html#cmd.Cmd

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

So a CLI shell then?

 

What you basically need to do is build an interpreter for the CLI. Here's a good guide for a simple interpreter I found : http://www.ruslanspivak.com/lsbasi-part1/ . The article doesn't cover what you are trying to achieve , but rather something which has the same principles as its base.

 

What you are trying to do is really easy to do in Python , where you can make your own CLI derived from cmd class built into the programming language. Here's more documentation : https://docs.python.org/2/library/cmd.html#cmd.Cmd

I figured out that python which is base of power shell will have simpler commands but one thing that stops me is i have 0 knownlegde on this langauge and since on coding lessons we got java and i have fresh knownlegde on it than i try do this stuff on java for that matter becasue it will make things a little bit simpler since i know basic structure of classes but still will at least try your advice too ;p

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

okay i made something but how can i post it on forum from my computer by not using some third party website?

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

okay i made something but how can i post it on forum from my computer by not using some third party website?

 

Just use code tags and if there's lots then wrap them logically in spoiler tags.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Just use code tags and if there's lots then wrap them logically in spoiler tags.

but its image cuz i used netbeans for first time and set some window add jframtextfield and textarea but they both look indentical to each other so which one i should use and how can post my picture of currently set objects fromy my computer ?

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

but its image cuz i used netbeans for first time and set some window add jframtextfield and textarea but they both look indentical to each other so which one i should use and how can post my picture of currently set objects fromy my computer ?

Firstly why are you not using IntelliJ if you are trying to use Java?

Secondly you are having problems understanding how to capture the/part of your screen? And how to host the result for display here?

It seems to me that you are struggling with even basic IT.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Firstly why are you not using IntelliJ if you are trying to use Java?

Secondly you are having problems understanding how to capture the/part of your screen? And how to host the result for display here?

It seems to me that you are struggling with even basic IT.

first i only knew the BlueJ and Eclipse which BlueJ was enough for me at that time

second i know how to capture part of screen or more accurate a running program but wanted to know if there is a way on this forum to upload it without using other sites :D

 

Here is an image:

http://imgur.com/P6At5bS

 

P.S.

Funny when i tried to use image button with link above the error text message appeard that says i am not allowed to use this extension on this community heh;p

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

first i only knew the BlueJ and Eclipse which BlueJ was enough for me at that time

second i know how to capture part of screen or more accurate a running program but wanted to know if there is a way on this forum to upload it without using other sites :D

 

Here is an image:

http://imgur.com/P6At5bS

 

P.S.

Funny when i tried to use image button with link above the error text message appeard that says i am not allowed to use this extension on this community heh;p

 

Ok you have some controls on a form in Java... I thought that you had to roll a console application - a text based interface?

 

If you are targeting this for a Windows platform then why Java. Do you have a language stipulation? I thought you were free to use any.

 

If all you have to do is wrap some file/directory manipulation functions then why not simply roll a C# console application? C# has all of the file/directory manipulation functions readily available (in a simple way). Put your own console interface around those... Visual Studio is even free for you to grab.

 

If it were me I'd probably choose Python for implementing this...

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

As i mention many times before i am fresh minded in java (what i mean by that is i know some commands and its structures so for now its kinda easier for me to come up with something)

c# - i have no idea how to even output simple text cuz i got no lessons and didint study it.

python - same as c# with a lite diffrence that i tried it but it was long ago and too little to make some simple programs

java kinda reminds me of javascript and i know they are not same but things i learned when i studied javascript a lot helped me out with

i hope that explains why i firstly spoke about java.

p.s. one more thing about python that i know is that the python is strongly connected to powershell and is one of basis of windows know (after asembler :P)

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

As i mention many times before i am fresh minded in java (what i mean by that is i know some commands and its structures so for now its kinda easier for me to come up with something)

c# - i have no idea how to even output simple text cuz i got no lessons and didint study it.

python - same as c# with a lite diffrence that i tried it but it was long ago and too little to make some simple programs

java kinda reminds me of javascript and i know they are not same but things i learned when i studied javascript a lot helped me out with

i hope that explains why i firstly spoke about java.

p.s. one more thing about python that i know is that the python is strongly connected to powershell and is one of basis of windows know (after asembler :P)

 

Ok so you have made the decision to go ahead with this in Java. You still haven't answered the main question though: You have some components placed on a form in Java - didn't you say that it had to be a text based interface? i.e. command line.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

For this kind of stuff if you don't need multiplatform and you are on Windows use the .NET framework, everything you need is basically already there you won't have to code a lot.

Link to comment
Share on other sites

Link to post
Share on other sites

Ok so you have made the decision to go ahead with this in Java. You still haven't answered the main question though: You have some components placed on a form in Java - didn't you say that it had to be a text based interface? i.e. command line.

Oh yes it should be but i dont know which component aka textarea or textfield are needed cuz its my first such project (i though i need to write source code and run it in cmd and make it look like cmd in cmd but the window idea is better thou) and which i should code only.

 

So to make it clean i asked which i should leave and which one i should delete aka is not necessery . Than we can proceed with coding which some ideas i have in my head but dont know how to code them for now ;P

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

For this kind of stuff if you don't need multiplatform and you are on Windows use the .NET framework, everything you need is basically already there you won't have to code a lot.

 

That's essentially his best option since knowledge of C# can be readily inferred from a Java context.

 

Oh yes it should be but i dont know which component aka textarea or textfield are needed cuz its my first such project (i though i need to write source code and run it in cmd and make it look like cmd in cmd but the window idea is better thou) and which i should code only.

 

So to make it clean i asked which i should leave and which one i should delete aka is not necessery . Than we can proceed with coding which some ideas i have in my head but dont know how to code them for now ;P

 

It's still not really clear why you are trying to use a form at all... you want a text based interface so just get rid of it and use a command line application template to go forward with, for instance:

public static void main(String[] args){   // TODO: Your code}

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

Throwing some tips around:

  • Use something like text area (the forum post where you type stuff) for the display.
  • Use File class for file management like move, copy, etc.
  • Make [Enter] key the trigger to start finding out what commands have been entered, if it complies with the syntax (use regex or something to do that), execute and display the outcome.
  • Decide if you want to copy Windows cmd or powershell commands (or other command line structures).cmd-bat.gif

I highly recommend doing it on your own as you'll need to complete similar projects one way or another on your course.

this quote make me do this window that is on the image  basicly. So i dont need to make this form by just create functions for it and run in cmd?

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

this quote make me do this window that is on the image  basicly. So i dont need to make this form by just create functions for it and run in cmd?

 

Essentially... if I am interpreting both what you are saying and your requirements correctly then yes dump the complexity and make a very simple command line application.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites



import java.util.Scanner;

import java.io.File;

 

class crf{

 Scanner user_input = new Scanner(System.in);

 String filename=user_input.next();

 String Userpath = getPath();

 }

 

 

public class SystemShell {

 

    public void createf(String filename, String Userpath){

     mkdir(filename);

     System.out.println(Userpath + " ");

 }

    public static void main(String[] args) {

         String Userpath1 = getPath();

       System.out.println(Userpath1 + " ");

       

    }

    

}



okay made somthing like this and i get error with function of java.io.File any ideas why and ma i doing the work in right direction?

 

edit: small tweaks to structure but still same question;

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

okay made somthing like this and i get error with function of java.io.File any ideas why and ma i doing the work in right direction?
 
edit: small tweaks to structure but still same question;

 

Your first problem is easy to spot.

 

Heres a clue:

PZ20Fqo.png

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

class crf { Scanner user_input = new Scanner(System.in); String filename=user_input.next(); String Userpath =  System.getProperty("user.dir");   public void createf(String filename, String Userpath){     File createfolder = new File(filename, Userpath);     createfolder.mkdir();     System.out.println(Userpath + " "); } }public class SystemShell {    public static void main(String[] args) {        Scanner user_input = new Scanner(System.in);        crf newFolder = new crf();       String Userpath1 = System.getProperty("user.dir");       String komenda = user_input.next();         System.out.println(Userpath1 + " " );       if (komenda==("crf"+newFolder.filename)){       newFolder.createf(newFolder.filename, newFolder.Userpath);       }    }    }

 

 

 

 

i done another tweaks and the program shows current location but what can i do to make program freeze untill lets say user wont type exit ?

 

EDIT:

Another tweaks and now another question how to place user input next to user location? so that it will look a little bit similar to cmd and after i added the if with "komenda" than my location output does not show up anymore any hints?

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

i done another tweaks and the program shows current location but what can i do to make program freeze untill lets say user wont type exit ?

 

EDIT:

Another tweaks and now another question how to place user input next to user location? so that it will look a little bit similar to cmd and after i added the if with "komenda" than my location output does not show up anymore any hints?

 

Here's a quick example:

import java.util.Scanner;public class Main{    public static void main(String[] args)    {        final String ExitCondition = "exit";	Scanner scanner = new Scanner(System.in);        String input;        printMenu();        do        {            System.out.print("Prompt> ");            input = scanner.nextLine();            System.out.println(input);        } while (!input.toLowerCase().equals(ExitCondition));        System.out.println("Program terminated");    }    private static void printMenu()    {        System.out.println("Simple user input demonstration:");        System.out.println("Enter some text to see it repeated or enter 'Exit' to quit.");    }}

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

 

Here's a quick example:

import java.util.Scanner;public class Main{    public static void main(String[] args)    {        final String ExitCondition = "exit";	Scanner scanner = new Scanner(System.in);        String input;        printMenu();        do        {            System.out.print("Prompt> ");            input = scanner.nextLine();            System.out.println(input);        } while (!input.toLowerCase().equals(ExitCondition));        System.out.println("Program terminated");    }    private static void printMenu()    {        System.out.println("Simple user input demonstration:");        System.out.println("Enter some text to see it repeated or enter 'Exit' to quit.");    }}

can i make it class like exit system or smth and import it to my main class or i need to implement it inside my SystemShell class?

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

can i make it class like exit system or smth and import it to my main class or i need to implement it inside my SystemShell class?

 

You can (and should) structure your application however you like. We will be able to help you with your architecture once you have more of your application built.

The single biggest problem in communication is the illusion that it has taken place.

Link to comment
Share on other sites

Link to post
Share on other sites

okay i made some changes with help of your example (kinda copy paste it but it helped :3)

import java.util.Scanner;import java.io.File;class crf { Scanner user_input = new Scanner(System.in); String filename;   public void createf(String filename){       filename=user_input.next();     File createfolder = new File(getDataFolder(), filename);     createfolder.mkdir();     } }   public class SystemShell {     public static void main(String[] args) {        final String ExitCondition = "exit";        Scanner user_input = new Scanner(System.in);        String Userpath1 = System.getProperty("user.dir");        String komenda;  do        {            System.out.print(Userpath1 +" ");            komenda = user_input.nextLine();        } while (!komenda.toLowerCase().equals(ExitCondition)); switch(komenda){     case "crf" :        crf newFolder = new crf();       if (komenda==("crf"+" "+newFolder.filename)){       newFolder.createf(newFolder.filename);        System.out.print(Userpath1 +" ");       }       break;         }    }}     

now i get a problem with my method, so first it does not create folder no matter what i type, second when i dug in the net i found getDataFolder() that is used for some codes from ppl and when i try to implement it it screams with error that he cant find symbol any idea how to make it work :S? because than i will create if statement that simple in metod and make move on to another classes :P

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

What kind of functionality do you actually need? Something like a basic file management system where you fire up a terminal, run your code, and you can manage folders and files?

bumping additional help cuz the Nulu has hands full propably (jugdin by breaks of his answer) and i hope it wont make any problems :P

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't think you need to write a second cmd that does actual file operations on disk, but rather a simulated filesystem and operations within it.

 

File management can be done with trees. It's pretty basic. I'd use C for it, simply because I am familiar with this sort of task on it and also because it's very transparent to use.

 

The logic is pretty much as follows:

 

make a root struct that includes a list of pointers to other identical structs and a list of files (by "files" I mean strings with names of fake files of course). It should also contain a name that identifies it (root in the first case).

 

Then make a function that adds structs to other structs as requested, which can in turn use a function that browses the tree for the required directory. With these two functions and a removal function (that frees a given struct and all the structs it points to) you have complete file management functionalities unless you want to be able to rename them too, in which case just add another function that does just that.

 

If, instead, you really need a program that does real modifications to the disk, you just need to google the java functions that concern I/O...

 

I don't have the time to do it for you at the moment and I don't think it's a good thing to do for you since you're supposed to learn how to do it yourself, but if in 25 days you haven't managed anything I *might* give it a spin for you - no promises though.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

I don't think you need to write a second cmd that does actual file operations on disk, but rather a simulated filesystem and operations within it.

 

File management can be done with trees. It's pretty basic. I'd use C for it, simply because I am familiar with this sort of task on it and also because it's very transparent to use.

 

The logic is pretty much as follows:

 

make a root struct that includes a list of pointers to other identical structs and a list of files (by "files" I mean strings with names of fake files of course). It should also contain a name that identifies it (root in the first case).

 

Then make a function that adds structs to other structs as requested, which can in turn use a function that browses the tree for the required directory. With these two functions and a removal function (that frees a given struct and all the structs it points to) you have complete file management functionalities unless you want to be able to rename them too, in which case just add another function that does just that.

 

If, instead, you really need a program that does real modifications to the disk, you just need to google the java functions that concern I/O...

 

I don't have the time to do it for you at the moment and I don't think it's a good thing to do for you since you're supposed to learn how to do it yourself, but if in 25 days you haven't managed anything I *might* give it a spin for you - no promises though.

unfortunetly it must do real modifications on disk such as creating a new folder that user wished for  than. ofc make some files make the function that allows user to move around folders

and so on. I try to google by myself most of functions and how to use them or implement but information i found and used so far didint work out.

For this issue i currently found that case maybe my varriable called filename (later i propably will change it to foldername for more clearance) that does not take any input from user because its inside another varriable that takes input too but i am not sure for 100 %.

 

Tbh i didint even get a clue from your method and i dont like C (we used it on our previous year it was a disaster for me after i was learning javascript alone back than ).

 

And ofc i appreciate the fact you want to throw rescue circle in critical time lol (although i made progress atleast got some basic code for now) :P

CPU i5 6600k 4,4Ghz , COOLER Dark Rock 3 from BQ, RAM 16 GB of ddr 4 2800MHz from corsair,

 PSU EVGA 750 W GOLD G2, MOBO Msi z170A Gaming M3, CASE NZXT H440 Black/Blue,

GPU Geforce GTX 980 Gigabyte G1 Gaming,

STORAGE 1 SSD Samsung 850 Evo 250 GB and 1 HDD 500GB WD, Windows 8.1.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×